-
Notifications
You must be signed in to change notification settings - Fork 25
Description
monet/monet_accessor.py
277 df["ascii2nc_gribcode"] = int(grib_code)
According to the MET docs the var column should come through as a string so as to allow for GRIB codes and string variables. The datatype in the column has the default data type as string.
(see Table 37.2):
https://met.readthedocs.io/en/latest/Users_Guide/appendixF.html#python-embedding-for-point-observations
As it sits now, in order to use this code for python embedding I'm restricted to using an integer to define variables, which isn't always going to be the case.
Here's an example of how I'm using monet and a line of output to illustrate:
dates = pd.date_range(start='2017-09-25',end='2017-09-26',freq='h')
df = pd.DataFrame
df = monetio.aeronet.add_data(dates=dates, product='AOD15')
#print (df.columns.tolist())
print (df["sensor_temperature(degrees_c)"])
point_data = df.monet.to_ascii2nc_list(
grib_code=2,
height_msl=None,
column="sensor_temperature(degrees_c)",
message_type="AERONET AOD15",
pressure=1000.0, # level
qc=None,
height_agl=None)
print (point_data)
message type : station ID : valid time : lat : lon : msl : var : level : agl : qc : val
['AERONET AOD15', 'Huambo', '20170925_103207', -12.8679, 15.7046, None, '2', 1000.0, None, '0', 34.4]
From monet/monet_accessor.py
def to_ascii2nc_df(
self,
grib_code=126,
height_msl=0.0,
column="aod_550nm",
message_type="ADPUPA",
pressure=1000.0,
qc=None,
height_agl=None,
):
df = self._obj
df["ascii2nc_time"] = df.time.dt.strftime("%Y%m%d_%H%M%S")
df["ascii2nc_gribcode"] = int(grib_code)
grib_code is our variable and it won't always be an integer. For instance, I pulled in AERONET data using monetio and when converting that data to the list required by MET I'd like to pick from the column names that get output when I first create the dataframe using:
df = monetio.aeronet.add_data(dates=dates, product='AOD15') print (df.columns.tolist())
Since these variables aren't in grib codes I can't exactly translate what they are to the MET output.
The docs dictate that the var column should contain strings so the following changes ought to remedy it.
267 ascii2nc_var=126,
277 df["ascii2nc_var"] = str(ascii2nc_var)
307 "ascii2nc_var",
322 ascii2nc_var="var",