package org.das2.dataset; import org.das2.datum.LocationUnits; import org.das2.datum.Units; import org.das2.datum.DatumVector; import org.das2.datum.Datum; import org.das2.datum.UnitsUtil; import org.das2.datum.TimeUtil; import org.das2.stream.StreamProducer; import org.das2.stream.DataTransferType; import org.das2.stream.StreamScalarDescriptor; import org.das2.stream.StreamDescriptor; import org.das2.stream.StreamXDescriptor; import org.das2.stream.StreamException; import org.das2.stream.PacketDescriptor; import org.das2.util.FixedWidthFormatter; import java.io.*; import java.nio.channels.*; import java.text.*; import java.util.*; import java.util.Map.Entry; import org.das2.datum.UnitsConverter; import org.das2.qds.DDataSet; import org.das2.qds.QDataSet; import org.das2.qds.SemanticOps; import org.das2.qds.ops.Ops; import org.das2.qds.util.DataSetBuilder; /** * * @author Owner */ public class VectorUtil { public static double[] getXTagArrayDouble( DataSet vds, Units units ) { int ixmax= vds.getXLength(); double[] xx= new double[ixmax]; for ( int i=0; i0 && xx[result]>x ) result--; if ( result"); pout.println("Stream creation date: "+TimeUtil.now().toString()+""); pout.print(""); if ( vds.getXUnits() instanceof LocationUnits ) { base= xmin; offsetUnits= ((LocationUnits)base.getUnits()).getOffsetUnits(); if ( offsetUnits==Units.microseconds ) { offsetUnits= Units.seconds; } } pout.print("[01]\n"); pout.print(""); List planeIDs; if ( vds.getProperty("plane-list")!=null ) { planeIDs= (List)vds.getProperty("plane-list"); } else { planeIDs= new ArrayList(); planeIDs.add(""); } for ( int i=0; i"); } pout.print(""); NumberFormat xnf= new DecimalFormat("00000.000"); NumberFormat ynf= new DecimalFormat("0.00E00"); double dx= xmax.subtract(xmin).doubleValue(offsetUnits); for (int i=0; i=0 && x properties= vds.getProperties(); if ( properties!=null) { for ( Entry e: properties.entrySet() ) { String key= e.getKey(); sd.setProperty(key, e.getValue() ); } } DataTransferType xTransferType; DataTransferType yTransferType; if ( asciiTransferTypes ) { if ( UnitsUtil.isTimeLocation(vds.getXUnits()) ) { xTransferType= DataTransferType.getByName("time24"); } else { xTransferType= DataTransferType.getByName("ascii14"); } yTransferType= DataTransferType.getByName("ascii14"); } else { xTransferType= DataTransferType.getByName("sun_real8"); yTransferType= DataTransferType.getByName("sun_real4"); } if ( sendStreamDescriptor ) producer.streamDescriptor(sd); StreamXDescriptor xDescriptor = new StreamXDescriptor(); xDescriptor.setUnits(vds.getXUnits()); xDescriptor.setDataTransferType(xTransferType); PacketDescriptor pd = new PacketDescriptor(); pd.setXDescriptor(xDescriptor); String[] planeIds= DataSetUtil.getAllPlaneIds(vds); DatumVector[] yValues = new DatumVector[planeIds.length]; for ( int i=0; i0 ) { ax0 = sx0 / nn0; ay0 = sy0 / nn0; builder.putValue( points, ylog ? Math.exp(ay0) : ay0 ); xbuilder.putValue( points, xlog ? Math.exp(ax0) : ax0 ); wbuilder.putValue( points, nn0 ); points++; } i++; x0 = dxLimit * ( 0.5 + (int) Math.floor(p0/dxLimit) ); y0 = dyLimit * ( 0.5 + (int) Math.floor(p1/dyLimit) ); sx0 = p0*ww; sy0 = p1*ww; nn0 = ww; } if ( nn0>0 ) { ax0 = sx0 / nn0; ay0 = sy0 / nn0; builder.putValue( points, ylog ? Math.exp(ay0) : ay0 ); xbuilder.putValue( points, xlog ? Math.exp(ax0) : ax0 ); wbuilder.putValue( points, nn0 ); points++; } DDataSet xdsr= xbuilder.getDataSet(); org.das2.qds.DataSetUtil.putProperties(org.das2.qds.DataSetUtil.getDimensionProperties(xds,null), xdsr ); xdsr.putProperty( QDataSet.CADENCE, null ); DDataSet ydsr= builder.getDataSet(); org.das2.qds.DataSetUtil.putProperties(org.das2.qds.DataSetUtil.getDimensionProperties(ds,null), ydsr ); ydsr.putProperty( QDataSet.CADENCE, null ); ydsr.putProperty( QDataSet.DEPEND_0, xdsr ); ydsr.putProperty( QDataSet.WEIGHTS, wbuilder.getDataSet() ); return ydsr; } }