Skip to content

nwm_client: KeyError: 'model_configuration' #293

@jzleroy

Description

@jzleroy

I am getting an error when I use nwm_client to retrieve NWM v1.2 data from GCP. The error is occuring in line 252 of NWMFileClient.py

Here is the line that throws the error:

analysis_assim = model_data_client.get(
    configurations = ['short_range'],
    reference_times = ['20190529T00Z'],
    nwm_feature_ids = [15667583]
    )

And the error looks like this:

File [D:\repos\FluEgg-Development\nwm-fluegg\env\Lib\site-packages\hydrotools\nwm_client\NWMFileClient.py:252](file:///D:/repos/FluEgg-Development/nwm-fluegg/env/Lib/site-packages/hydrotools/nwm_client/NWMFileClient.py#line=251), in NWMFileClient.get(self, configurations, reference_times, nwm_feature_ids, variables, compute)
    250 df["measurement_unit"] = ds[var].attrs["units"]
    251 df["variable_name"] = var
--> 252 df["configuration"] = ds.attrs["model_configuration"]
    254 # Address ambigious "No-DA" cycle names
    255 if cfg.endswith("no_da"):

KeyError: 'model_configuration'

The netCDF files do download. When I manually import one of the netCDF files using xarray, there is no 'model_configuration' attribute in the v1.2 data.

here's a list of attributes from a v1.2 file for example:

{'featureType': 'timeSeries',
 'proj4': '+proj=longlat +datum=NAD83 +no_defs',
 'model_initialization_time': '2019-05-29_00:00:00',
 'station_dimension': 'feature_id',
 'model_output_valid_time': '2019-05-29_18:00:00',
 'stream_order_output': 1,
 'cdm_datatype': 'Station',
 'esri_pe_string': 'GEOGCS[GCS_North_American_1983,DATUM[D_North_American_1983,SPHEROID[GRS_1980,6378137.0,298.257222101]],PRIMEM[Greenwich,0.0],UNIT[Degree,0.017453292519943295]]',
 'Conventions': 'CF-1.6',
 'model_version': 'NWM 1.2',
 'dev_OVRTSWCRT': 1,
 'dev_NOAH_TIMESTEP': 3600,
 'dev_channel_only': 0,
 'dev_channelBucket_only': 0,
 'dev': 'dev_ prefix indicates development/internal meta data'}

and from a v2.0 file:

{'featureType': 'timeSeries',
 'proj4': '+proj=lcc +units=m +a=6370000.0 +b=6370000.0 +lat_1=30.0 +lat_2=60.0 +lat_0=40.0 +lon_0=-97.0 +x_0=0 +y_0=0 +k_0=1.0 +nadgrids=@',
 'model_initialization_time': '2020-05-29_00:00:00',
 'station_dimension': 'feature_id',
 'model_output_valid_time': '2020-05-29_18:00:00',
 'model_total_valid_times': 18,
 'stream_order_output': 1,
 'cdm_datatype': 'Station',
 'Conventions': 'CF-1.6',
 'code_version': 'v5.1.0-beta2',
 'NWM_version_number': 'v2.0',
 'model_output_type': 'channel_rt',
 'model_configuration': 'short_range',
 'dev_OVRTSWCRT': 1,
 'dev_NOAH_TIMESTEP': 3600,
 'dev_channel_only': 0,
 'dev_channelBucket_only': 0,
 'dev': 'dev_ prefix indicates development/internal meta data'}

Would be great if this error didn't totally disrupt the processing of getting the older v1.2 data, but I think I can work around it since the files do download.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions