nsrdb.albedo.albedo.CompositeAlbedoDay

class CompositeAlbedoDay(date, modis_path, ims_path, albedo_path, merra_path=None, max_workers=None)[source]

Bases: object

Combine IMS and MODIS data to create composite Albedo.

This class is intended to be used with the run() class method, which acquires IMS and MODIS data, merges the two, and a returns an instance of the class. Exporting albedo data to HDF5 or TIFF must be explicitly requested by the user using appropriate methods.

The composite albedo data is created by mapping the MODIS data to the IMS data using a KD tree to perform a nearest neighbor analysis using concurrent futures. Passing a KD tree based on the full IMS data to the futures proved problematic due to memory issues, so the IMS data is first reduced to the snow/no-snow boundary areas first, which reduces the size of the tree significantly.

Combining the two data sources takes roughly 15 minutes for older, 4 km IMS data, and 50 minutes for 1 km IMS data running on a 36 core HPC node.

run - Load all data and create composite albedo.
write_albedo - Write albedo data to HDF5 file.
write_tiff - Write albedo to georeferenced TIFF.
write_tiff_from_h5 - Load existing composite albedo data from HDF5 and

write to TIFF.

Parameters:
  • date (datetime instance) – Date to calculate composite albedo for

  • modis_path (str) – File path to MODIS hdf (NetCDF) data files. Data is downloaded and stored at this location if it not present.

  • ims_path (str) – File path to IMS data and metadata files. Data is downloaded and stored at this location if it not present.

  • albedo_path (str) – Path for composite albedo data files (output)

  • merra_path (str | None) – Path for merra data to use in albedo calculation. If None albedo will use constant value instead of calculating.

  • max_workers (int | None) – Max number of workers for concurrent futures, None is all

Methods

run(date, modis_path, ims_path, albedo_path)

Merge MODIS and IMS data for one day.

write_albedo()

Write albedo data to HDF5 file.

write_tiff([outfilename])

Write albedo data to TIFF and world file.

write_tiff_from_h5(infilename[, outfilename])

Write albedo data to TIFF and world file.

Attributes

ALBEDO_ATTRS

CHUNKS

SNOW_ALBEDO

classmethod run(date, modis_path, ims_path, albedo_path, merra_path=None, ims_shape=None, modis_shape=None, max_workers=None, ims_buffer=6)[source]

Merge MODIS and IMS data for one day.

Parameters:
  • date (datetime instance) – Date to calculate composite albedo for

  • modis_path (str) – File path to MODIS hdf (NetCDF) data files. Data is downloaded and stored at this location if not present.

  • ims_path (str) – File path to IMS data and metadata files. Data is downloaded and stored at this location if not present.

  • albedo_path (str) – Path for composite albedo data files (output)

  • merra_path (str | None) – Path for merra data to use in albedo calculation. If None albedo will use constant value instead of calculating.

  • ims_shape ((int, int)) – Shape of IMS data (rows, cols). Defaults to typical shape of IMS data. Should be None unless testing.

  • modis_shape ((int, int)) – Shape of MODIS data (rows, cols). Defaults to typical shape of MODIS data. Should be None unless testing.

  • max_workers (int | None) – Max number of workers for concurrent futures, None is all

  • ims_buffer (int) – Number of times to buffer points used to define IMS snow/no snow edge in KD tree.

Returns:

Class instance

write_albedo()[source]

Write albedo data to HDF5 file. Albedo data is assumed to be scaled to np.uint8.

Parameters:

path (string) – Location to save albedo data to

write_tiff(outfilename=None)[source]

Write albedo data to TIFF and world file. Geo referencing appears to be off by 5 meters.

Parameters:

outfilename (string | None) – Path and file name for TIFF and world file. Uses default if None.

classmethod write_tiff_from_h5(infilename, outfilename=None)[source]

Write albedo data to TIFF and world file. Geo referencing appears to be off by 5 meters.

Parameters:
  • infilename (string) – Path and file name of albedo h5 file

  • outfilename (string) – Path and file name for TIFF and world file. Defaults to infilename with .tif extension