def test_identify_variable(self): checklist = [('time', 'time'), ('latitude', 'lat'), ('longitude', 'lon'), ('atmosphere_hybrid_pressure_coordinate', 'hyam'), ('atmosphere_hybrid_height_coordinate', 'hybm'), ('cloud_area_fraction_in_atmosphere_layer', 'cloud_area_fraction_in_atmosphere_layer')] for standard_name, short_name in checklist: variable = identify_variable(self.ncfile_ml, standard_name) assert variable[0] == short_name
def _find_data_vars(self): """Find NetCDF variables of required data fields. A dictionary data_vars is created. Its keys are the CF standard names of the variables provided by the plot object. The values are pointers to the NetCDF variable objects. <data_vars> can be accessed as <self.data_vars>. """ self.data_vars = {} self.data_units = {} for df_type, df_name, _ in self.plot_object.required_datafields: varname, var = netCDF4tools.identify_variable(self.dataset, df_name, check=True) logging.debug("\tidentified variable <%s> for field <%s>", varname, df_name) self.data_vars[df_name] = var self.data_units[df_name] = getattr(var, "units", None)