diff --git a/glmtools/grid/make_grids.py b/glmtools/grid/make_grids.py index 3d110ba..229e454 100644 --- a/glmtools/grid/make_grids.py +++ b/glmtools/grid/make_grids.py @@ -595,20 +595,25 @@ def output_setup(self, *args, **kwargs): self.divide_grids[2]=0 self.divide_grids[6]=4 - + def write_grids(self, outpath = '', output_writer = None, output_writer_3d = None, output_filename_prefix = None, output_kwargs={}): - + + #print('output_filename_prefix=',output_filename_prefix) pad = output_kwargs.pop('pad', None) - scale_and_offset = output_kwargs.pop('scale_and_offset', True) + # changed by feng for isatss on sep. 04,2019 + # no scale and offset for outputs; + # use 'output_filename_prefix' for output filename. + #scale_and_offset = output_kwargs.pop('scale_and_offset', True) + scale_and_offset = False from glmtools.io.imagery import write_goes_imagery all_outfiles = write_goes_imagery(self, outpath=outpath, pad=pad, - scale_and_offset=scale_and_offset) + output_filename_prefix=output_filename_prefix, scale_and_offset=scale_and_offset) + #end by feng return all_outfiles - def subdivide_bnd(bnd, delta, s=8): """ Subdivide a range (edges of the span) into s equal length @@ -808,6 +813,7 @@ def grid_GLM_flashes(GLM_filenames, start_time, end_time, **kwargs): process_flash_kwargs['lat_bnd'] = kwargs['y_bnd'] subgrids = [((0, 0), kwargs, process_flash_kwargs, out_kwargs, pads)] elif 'fixed_grid' in process_flash_kwargs: + #out_kwargs['calculate_2D_lonlat'] = False subgrids = subdivided_fixed_grid(kwargs, process_flash_kwargs, out_kwargs, s=subdivide_grid) else: @@ -820,12 +826,12 @@ def grid_GLM_flashes(GLM_filenames, start_time, end_time, **kwargs): this_proc_each_grid = partial(proc_each_grid, start_time=start_time, end_time=end_time, GLM_filenames=GLM_filenames) - # if subdivide_grid > 1: - # pool = ProcessPoolExecutor(max_workers=4) - # with pool: - # # Block until the pool completes (pool is a context manager) - # outputs = pool.map(this_proc_each_grid, subgrids) - # else: + #if subdivide_grid > 1: + # pool = ProcessPoolExecutor(max_workers=4) + # with pool: + # # Block until the pool completes (pool is a context manager) + # outputs = pool.map(this_proc_each_grid, subgrids) + #else: outputs = list(map(this_proc_each_grid, subgrids)) for op in outputs: log.debug(outputs) @@ -852,7 +858,7 @@ def proc_each_grid(subgrid, start_time=None, end_time=None, GLM_filenames=None): GLM_filenames -- a list of GLM filenames to process """ - subgridij, kwargsij, process_flash_kwargs_ij, out_kwargs_ij, pads = subgrid + subgridij, kwargsij, process_flash_kwargs_ij, out_kwargs_ij, pads = subgrid ellipse_rev = process_flash_kwargs_ij.pop('ellipse_rev') # Eventually, we want to trim off n_x/y_pad from each side of the grid diff --git a/glmtools/io/imagery.py b/glmtools/io/imagery.py index 1552ac6..d7f4251 100644 --- a/glmtools/io/imagery.py +++ b/glmtools/io/imagery.py @@ -184,10 +184,10 @@ def get_goes_imager_fixedgrid_coords(x, y, resolution='2km at nadir', two_km_enc = { 'FULL':{'dtype':'int16', 'x':{'scale_factor': 0.000056, 'add_offset':-0.151844, - '_FillValue':-999.0}, + '_FillValue':fill}, 'y':{'scale_factor':-0.000056, 'add_offset':0.151844, - '_FillValue':-999.0}, + '_FillValue':fill}, }, # The PUG has specific values for the CONUS sector, and # given the discretization of the coords to 2 km resolution, is it necessary @@ -204,11 +204,14 @@ def get_goes_imager_fixedgrid_coords(x, y, resolution='2km at nadir', # two_km_enc['OTHER'] = two_km_enc['MESO1'] x_meta, y_meta = {}, {} - x_enc = two_km_enc['FULL']['x'] - x_enc['dtype'] = two_km_enc[scene_id]['dtype'] - y_enc = two_km_enc['FULL']['y'] - y_enc['dtype'] = two_km_enc[scene_id]['dtype'] - + # changed by feng for isatss on sep 04, 2019 + #x_enc = two_km_enc['FULL']['x'] + #x_enc['dtype'] = two_km_enc[scene_id]['dtype'] + #y_enc = two_km_enc['FULL']['y'] + #y_enc['dtype'] = two_km_enc[scene_id]['dtype'] + x_enc = {'dtype':'float32','_FillValue':fill} + y_enc = {'dtype':'float32','_FillValue':fill} + # end by feng x_meta['axis'] = "X" x_meta['long_name'] = "GOES fixed grid projection x-coordinate" @@ -435,7 +438,8 @@ def infer_scene_from_dataset(x, y): scene_id = "OTHER" return scene_id -def write_goes_imagery(gridder, outpath='.', pad=None, scale_and_offset=True): +# add one argument "output_filename_prefix" to def write_goes_imagery by feng on sep 04, 2019 +def write_goes_imagery(gridder, outpath='.', pad=None, output_filename_prefix=None, scale_and_offset=True): """ pad is a tuple of x_slice, y_slice: slice objects used to index the zeroth and first dimensions, respectively, of the grids in gridder. @@ -482,6 +486,7 @@ def write_goes_imagery(gridder, outpath='.', pad=None, scale_and_offset=True): dataset, scene_id = new_goes_imagery_dataset(x_coord, np.flipud(y_coord), nadir_lon) + #closed by feng for isatss on sep. 04, 2019 # Global metadata global_attrs = get_glm_global_attrs(start, end, "G16", "GOES-East", "GLM-1", scene_id, @@ -491,7 +496,11 @@ def write_goes_imagery(gridder, outpath='.', pad=None, scale_and_offset=True): # log.debug("*** Checking x coordinate attrs initial") # log.debug(dataset.x.attrs) - outfile = os.path.join(outpath, dataset.attrs['dataset_name']) + #outfile = os.path.join(outpath, dataset.attrs['dataset_name']) + + dataset_name = output_filename_prefix+"_whole_fields.nc" + outfile = os.path.join(outpath, dataset_name) + # end by feng # Adding a new variable to the dataset below clears the coord attrs # so hold on to them for now. @@ -651,4 +660,4 @@ def open_glm_time_series(filenames, chunks=None): d.attrs['time_coverage_start'] = pd.Timestamp(min(starts)).isoformat() d.attrs['time_coverage_end'] = pd.Timestamp(max(ends)).isoformat() - return d \ No newline at end of file + return d