runtraj.models.hysplit.read_cdump#

runtraj.models.hysplit.read_cdump(path, cmass=0, ichem=0, pollutant=None)[source]#

Read one of HYSPLIT’s binary concentration files (cdump) as a Dataset.

The file holds one grid: its header (the met, the release locations, the grid, the levels, the pollutants), then, for each sampling time, one record per pollutant per level. With CPACK=1 (HYSPLIT’s default; 3 is written the same way) a record lists only the cells that are not zero; with CPACK=0 it holds every cell. Both read to the same Dataset.

Parameters:
  • path (str | Path) – The file hycs_std wrote.

  • cmass (int) – The cmass setting the run had: 0 for concentrations, anything else for the mass in each cell. The file does not say, and the variables’ units and long_name do.

  • ichem (int) – The ichem setting the run had, which the file does not say either. With 6 the values are divided by air density, and the units say so. With 9 the first level reaches from the ground to a share of the mixed layer, and z says so. With 1 or 10 what the file calls its pollutants are the release locations or the emission cycles of one pollutant, and the Dataset has one variable, named pollutant, with a dimension more (see Notes).

  • pollutant (str | None) – The name of the run’s one pollutant, with ichem 1 or 10, which the file does not hold.

Returns:

Dimensions time, z, lat, lon, and a float32 variable per pollutant, as the module describes. lat and lon are the decimal degrees the grid was given, not the 4-byte floats the file holds (40.266, not 40.26599884). Its attributes hold cpack, met_model (the met’s four-letter name), and the release locations as [[lon, lat, height], ...]. Two-digit years are read as 1940 to 2039.

Return type:

Dataset

Notes

With ichem=1 HYSPLIT numbers the release locations in the place of the pollutants (0001, 0002, …). They are read as the dimension source, 1 to the number of locations, in the order of the release’s points, with the coordinates source_lon, source_lat and source_height from the file’s header.

With ichem=10 HYSPLIT names each emission cycle by the tenths of an hour from the start of the run to the cycle’s start. They are read as the dimension release_time, the UTC time each cycle starts.

With ichem=9 each record of the first level holds the depth that level had for the last particle counted, in place of its height, so that depth is not checked, and not kept.

Raises:

ValueError – If the file is cut off, is not a concentration file, or was written with CPACK=2 (one point per grid), which this does not read; or if its pollutants are not what ichem 1 or 10 writes.

Parameters:
Return type:

Dataset

Examples

>>> ds = read_cdump("cdump")
>>> ds["TEST"].sel(z=100).max()