public static final GeoTimeSerie subCycleSerie(GeoTimeSerie gts,long lastbucket,int buckets_per_period,boolean overwrite,GeoTimeSerie subgts) throws WarpScriptException {
  if (!isBucketized(gts)) {
    throw new WarpScriptException("GTS must be bucketized");
  }
  if (0 != (gts.lastbucket - lastbucket) % gts.bucketspan) {
    throw new WarpScriptException("lasbucket parameter of subCycleSerie method must fall on an actual bucket of the gts input");
  }
  if (null == subgts) {
    subgts=new GeoTimeSerie(lastbucket,(gts.bucketcount - (int)((gts.lastbucket - lastbucket) / gts.bucketspan) - 1) / buckets_per_period + 1,gts.bucketspan * buckets_per_period,(int)Math.max(1.4 * gts.bucketcount,gts.sizehint) / buckets_per_period);
  }
 else {
    subgts.values=0;
    subgts.type=TYPE.UNDEFINED;
    subgts.lastbucket=lastbucket;
    subgts.bucketcount=(gts.bucketcount - (int)((gts.lastbucket - lastbucket) / gts.bucketspan) - 1) / buckets_per_period + 1;
    subgts.bucketspan=gts.bucketspan * buckets_per_period;
  }
  if (null == gts.ticks || 0 == gts.values) {
    return subgts;
  }
  Iterator<Long> iter=tickIterator(subgts,true);
  long tick;
  sort(gts);
  int i=gts.values;
  while (iter.hasNext()) {
    tick=iter.next();
    i=Arrays.binarySearch(gts.ticks,0,i,tick);
    if (i >= 0) {
      setValue(subgts,gts.ticks[i],null != gts.locations ? gts.locations[i] : GeoTimeSerie.NO_LOCATION,null != gts.elevations ? gts.elevations[i] : GeoTimeSerie.NO_ELEVATION,valueAtIndex(gts,i),overwrite);
    }
  }
  return subgts;
}

public static final GeoTimeSerie subCycleSerie ( GeoTimeSerie gts , long lastbucket , int buckets_per_period , boolean overwrite , GeoTimeSerie subgts ) throws WarpScriptException { if ( ! isBucketized ( gts ) ) { throw new WarpScriptException ( "GTS must be bucketized" ) ; } if ( 0 != ( gts . lastbucket - lastbucket ) % gts . bucketspan ) { throw new WarpScriptException ( "lasbucket parameter of subCycleSerie method must fall on an actual bucket of the gts input" ) ; } if ( null == subgts ) { subgts = new GeoTimeSerie ( lastbucket , ( gts . bucketcount - ( int ) ( ( gts . lastbucket - lastbucket ) / gts . bucketspan ) - 1 ) / buckets_per_period + 1 , gts . bucketspan * buckets_per_period , ( int ) Math . max ( 1.4 * gts . bucketcount , gts . sizehint ) / buckets_per_period ) ; } else { subgts . values = 0 ; subgts . type = TYPE . UNDEFINED ; subgts . lastbucket = lastbucket ; subgts . bucketcount = ( gts . bucketcount - ( int ) ( ( gts . lastbucket - lastbucket ) / gts . bucketspan ) - 1 ) / buckets_per_period + 1 ; subgts . bucketspan = gts . bucketspan * buckets_per_period ; } if ( null == gts . ticks || 0 == gts . values ) { return subgts ; } Iterator < Long > iter = tickIterator ( subgts , true ) ; long tick ; sort ( gts ) ; int i = gts . values ; while ( iter . hasNext ( ) ) { tick = iter . next ( ) ; i = Arrays . binarySearch ( gts . ticks , 0 , i , tick ) ; if ( i >= 0 ) { setValue ( subgts , gts . ticks [ i ] , null != gts . locations ? gts . locations [ i ] : GeoTimeSerie . NO_LOCATION , null != gts . elevations ? gts . elevations [ i ] : GeoTimeSerie . NO_ELEVATION , valueAtIndex ( gts , i ) , overwrite ) ; } } return subgts ; }
return a new geotimeserie instance containing only the values of ' gts ' that fall under timestamps that are bound by the same modulo class . the resulting gts instance will be sorted and bucketized .
