def proc_modscag(fn_list, extent=None, t_srs=None):
    """Process the MODSCAG products for full date range, create composites and reproject
    """
    #Use cubic spline here for improve upsampling 
    ds_list = warplib.memwarp_multi_fn(fn_list, res='min', extent=extent, t_srs=t_srs, r='cubicspline')
    stack_fn = os.path.splitext(fn_list[0])[0] + '_' + os.path.splitext(os.path.split(fn_list[-1])[1])[0] + '_stack_%i' % len(fn_list) 
    #Create stack here - no need for most of mastack machinery, just make 3D array
    #Mask values greater than 100% (clouds, bad pixels, etc)
    ma_stack = np.ma.array([np.ma.masked_greater(iolib.ds_getma(ds), 100) for ds in np.array(ds_list)], dtype=np.uint8)

    stack_count = np.ma.masked_equal(ma_stack.count(axis=0), 0).astype(np.uint8)
    stack_count.set_fill_value(0)
    stack_min = ma_stack.min(axis=0).astype(np.uint8)
    stack_min.set_fill_value(0)
    stack_max = ma_stack.max(axis=0).astype(np.uint8)
    stack_max.set_fill_value(0)
    stack_med = np.ma.median(ma_stack, axis=0).astype(np.uint8)
    stack_med.set_fill_value(0)

    out_fn = stack_fn + '_count.tif'
    iolib.writeGTiff(stack_count, out_fn, ds_list[0])
    out_fn = stack_fn + '_max.tif'
    iolib.writeGTiff(stack_max, out_fn, ds_list[0])
    out_fn = stack_fn + '_min.tif'
    iolib.writeGTiff(stack_min, out_fn, ds_list[0])
    out_fn = stack_fn + '_med.tif'
    iolib.writeGTiff(stack_med, out_fn, ds_list[0])

    ds = gdal.Open(out_fn)
    return ds
def proc_modscag ( fn_list , extent = None , t_srs = None ) : ds_list = warplib . memwarp_multi_fn ( fn_list , res = 'min' , extent = extent , t_srs = t_srs , r = 'cubicspline' ) stack_fn = os . path . splitext ( fn_list [ 0 ] ) [ 0 ] + '_' + os . path . splitext ( os . path . split ( fn_list [ - 1 ] ) [ 1 ] ) [ 0 ] + '_stack_%i' % len ( fn_list ) ma_stack = np . ma . array ( [ np . ma . masked_greater ( iolib . ds_getma ( ds ) , 100 ) for ds in np . array ( ds_list ) ] , dtype = np . uint8 ) stack_count = np . ma . masked_equal ( ma_stack . count ( axis = 0 ) , 0 ) . astype ( np . uint8 ) stack_count . set_fill_value ( 0 ) stack_min = ma_stack . min ( axis = 0 ) . astype ( np . uint8 ) stack_min . set_fill_value ( 0 ) stack_max = ma_stack . max ( axis = 0 ) . astype ( np . uint8 ) stack_max . set_fill_value ( 0 ) stack_med = np . ma . median ( ma_stack , axis = 0 ) . astype ( np . uint8 ) stack_med . set_fill_value ( 0 ) out_fn = stack_fn + '_count.tif' iolib . writeGTiff ( stack_count , out_fn , ds_list [ 0 ] ) out_fn = stack_fn + '_max.tif' iolib . writeGTiff ( stack_max , out_fn , ds_list [ 0 ] ) out_fn = stack_fn + '_min.tif' iolib . writeGTiff ( stack_min , out_fn , ds_list [ 0 ] ) out_fn = stack_fn + '_med.tif' iolib . writeGTiff ( stack_med , out_fn , ds_list [ 0 ] ) ds = gdal . Open ( out_fn ) return ds
Process the MODSCAG products for full date range, create composites and reproject