package org.das2.qds; /** * return a rank N-1 dataset from a rank N dataset by slicing on the fourth * dimension. (Rank 4 supported.) * * plane datasets are sliced as well, when they have rank 4 or greater. * * @author jbf */ public final class Slice3DataSet extends AbstractDataSet { QDataSet ds; int index; public Slice3DataSet(QDataSet ds, int index) { this( ds, index, true ); } Slice3DataSet( QDataSet ds, int index, boolean addContext ) { if (ds.rank() > 4 ) { throw new IllegalArgumentException("rank limit > 4"); } if ( ds.rank() < 4 ) { throw new IllegalArgumentException("rank limit < 4"); } this.ds = ds; this.index = index; if ( addContext ) { QDataSet bundle= (QDataSet) ds.property( QDataSet.BUNDLE_3 ); QDataSet dep3= (QDataSet) ds.property(QDataSet.DEPEND_3); if ( bundle!=null && dep3==null ) { QDataSet context=null; if ( addContext ) { context= DataSetOps.getContextForUnbundle( bundle, index ); DataSetUtil.addContext( this, context ); putProperty( QDataSet.NAME, bundle.property(QDataSet.NAME,index) ); } } else { if ( dep3!=null ) { if ( dep3.rank()==1 ) { DataSetUtil.addContext( this, new Slice0DataSet(dep3,index,false) ); } else if ( dep3.rank()==2 ) { DataSetUtil.addContext( this, new Slice1DataSet(dep3,index,false) ); } else { System.err.println( "slice on non-qube, dep3 has rank="+dep3.rank() ); } } else { DRank0DataSet context= DataSetUtil.asDataSet(index); context.putProperty( QDataSet.NAME, "slice3" ); DataSetUtil.addContext( this, context ); } } } putProperty( QDataSet.DEPEND_0, ds.property(QDataSet.DEPEND_0) ); putProperty( QDataSet.DEPEND_1, ds.property(QDataSet.DEPEND_1) ); putProperty( QDataSet.DEPEND_2, ds.property(QDataSet.DEPEND_2) ); putProperty( QDataSet.DEPEND_3, null ); putProperty( QDataSet.BUNDLE_0, ds.property( QDataSet.BUNDLE_0 ) ); putProperty( QDataSet.BUNDLE_1, ds.property( QDataSet.BUNDLE_1 ) ); putProperty( QDataSet.BUNDLE_2, ds.property( QDataSet.BUNDLE_2 ) ); putProperty( QDataSet.BINS_0, ds.property( QDataSet.BINS_0 ) ); putProperty( QDataSet.BINS_1, ds.property( QDataSet.BINS_1 ) ); for ( int i=0; i