Skip to content

Commit

Permalink
solved issue #197
Browse files Browse the repository at this point in the history
  • Loading branch information
paolap committed Oct 31, 2024
1 parent f015ad6 commit 07a136a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mappings/map_AUS2200.csv
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ hus;fld_s00i010;level_to_height(var[0],levs=(0,66));1;time model_theta_level_num
huslev1;fld_s00i010;;1;time lat lon;longitude latitude time1;10minPt;atmos;area: time: point;;AUS2200_A10min;AUS2200;float32;22048000;2304;umnsa_spec;SPECIFIC HUMIDITY AFTER TIMESTEP;surface_specific_humidity
huss;fld_s03i237;;1;time_0 lat lon;longitude latitude time height1.5m;1hr;atmos;area: time: mean;;AUS2200_A1hr;AUS2200;float32;22048000;384;umnsa_slv;SPECIFIC HUMIDITY AT 1.5M;specific_humidity
huss;fld_s03i237;;1;time lat lon;longitude latitude time1 height1.5m;10minPt;atmos;area: time: point;;AUS2200_A10min;AUS2200;float32;22048000;2304;umnsa_spec;SPECIFIC HUMIDITY AT 1.5M;specific_humidity
lmask;fld_s00i030;var[0].isel(time=0).astype(int);1;time_1 lat lon;longitude latitude;1hrPt;land;area: time: point;;AUS2200_fx;AUS2200;float64;44096000;384;umnsa_slv;LAND MASK (No halo) (LAND=TRUE);land_binary_mask
lmask;fld_s00i030;var[0].isel(time=0).astype(int);1;time_1 lat lon;longitude latitude;fx;land;area: time: point;;AUS2200_fx;AUS2200;float64;44096000;384;umnsa_slv;LAND MASK (No halo) (LAND=TRUE);land_binary_mask
lwp;fld_s30i405;;kg m-2;time lat lon;longitude latitude time1;10minPt;atmos;area: time: point;;AUS2200_A10min;AUS2200;float32;22048000;2304;umnsa_spec;TOTAL COLUMN QCL RHO GRID;atmosphere_cloud_liquid_water_content
mrso;fld_s08i223;var[0].sum(dim='depth');kg m-2;time depth lat lon;longitude latitude time1;1hrPt;land;area: time: point;;AUS2200_A1hr;AUS2200;float32;22048000;384;umnsa_slv;;
mrsol;fld_s08i223;;kg m-2;time depth lat lon;longitude latitude sdepth time1;1hrPt;land;area: time: point;;AUS2200_A1hr;AUS2200;float32;88192000;384;umnsa_slv;SOIL MOISTURE CONTENT IN A LAYER;mass_content_of_water_in_soil_layer
mrsos;fld_s08i223;calc_top_soil(var[0]);kg m-2;time depth lat lon;longitude latitude time1 sdepth1;1hrPt;land;area: time: point;;AUS2200_A1hr;AUS2200;float32;22048000;384;umnsa_slv;;
nflash;fld_s21i104;;1;time_0 lat lon;longitude latitude time;10min;atmos;area: time: sum;;AUS2200_A10min;AUS2200;float32;22048000;2304;umnsa_spec;Number_of_lightning_flashes;
orog;fld_s00i033;var[0].isel(time=0);m;time_1 lat lon;longitude latitude;1hrPt;land;area: time: point;;CMIP6_fx;AUS2200;float32;22048000;384;umnsa_slv;OROGRAPHY (/STRAT LOWER BC);surface_altitude
orog;fld_s00i033;var[0].isel(time=0);m;time_1 lat lon;longitude latitude;fx;land;area: time: point;;CMIP6_fx;AUS2200;float32;22048000;384;umnsa_slv;OROGRAPHY (/STRAT LOWER BC);surface_altitude
pfull;fld_s00i408;level_to_height(var[0],levs=(0,66));Pa;time model_theta_level_number lat lon_0;longitude latitude alevel time1;1hrPt;atmos;area: time: point;;AUS2200_A1hr;AUS2200;float32;1543360000;384;umnsa_mdl;PRESSURE AT THETA LEVELS AFTER TS;air_pressure
phalf;fld_s00i407;level_to_height(var[0],levs=(0,66));Pa;time model_rho_level_number_0 lat lon_0;longitude latitude alevel time1;1hrPt;atmos;area: time: point;;AUS2200_A1hr;AUS2200;float32;1565408000;384;umnsa_mdl;PRESSURE AT RHO LEVELS AFTER TS;air_pressure
pralsns;fld_s04i202;;kg m-2;time_0 lat lon;longitude latitude time;10min;atmos;area: time: sum;;AUS2200_A10min;AUS2200;float32;22048000;2304;umnsa_spec;LARGE SCALE SNOW AMOUNT KG/M2/TS;stratiform_snowfall_amount
Expand Down
Binary file modified src/mopdata/access.db
Binary file not shown.
6 changes: 3 additions & 3 deletions src/mopdata/access_dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@ INSERT INTO mapping VALUES('clw','fld_s00i254','level_to_height(var[0],levs=(0,6
INSERT INTO mapping VALUES('clw','fld_s02i308','level_to_height(var[0])','1','time model_theta_level_number lat lon','longitude latitude alevel time','mon','atmos','area: time: mean','','CMIP6_Amon','CM2','mass_fraction_of_stratiform_cloud_liquid_water_in_air','map_atmos_CM2.csv');
INSERT INTO mapping VALUES('clw','fld_s02i308','level_to_height(var[0])','1','time model_theta_level_number lat lon','longitude latitude alevel time','mon','atmos','area: time: mean','','CMIP6_Amon','ESM1.5','mass_fraction_of_stratiform_cloud_liquid_water_in_air','map_atmos_ESM1.5.csv');
INSERT INTO mapping VALUES('clwvol','fld_s00i267','level_to_height(var[0],levs=(0,66))','1','time model_theta_level_number lat lon','longitude latitude alevel time1','1hrPt','atmos','area: time: point','','AUS2200_A1hr','AUS2200','liquid_cloud_volume_fraction_in_atmosphere_layer','map_AUS2200.csv');
INSERT INTO mapping VALUES('cmor_var','input_vars','calculation','units','dimensions','axes','frequency','realm','cell_methods','positive','cmor_table','version','standard_name','map_seaice_CM2.csv');
INSERT INTO mapping VALUES('cmor_var','input_vars','calculation','units','dimensions','axes','frequency','realm','cell_methods','positive','cmor_table','version','standard_name','map_AUS2200.csv');
INSERT INTO mapping VALUES('cropFrac','fld_s03i317 fld_s03i395','extract_tilefrac(var[0],9,landfrac=var[1],lev=''typecrop'')','1','time lat lon','longitude latitude time typecrop','mon','land','area: mean where land over all_area_types time: mean','','CMIP6_Lmon','CM2','area_fraction','map_land_CM2.csv');
INSERT INTO mapping VALUES('cropFrac','fld_s03i317 fld_s03i395','extract_tilefrac(var[0],9,landfrac=var[1],lev=''typecrop'')','1','time lat lon','longitude latitude time typecrop','mon','land','area: mean where land over all_area_types time: mean','','CMIP6_Lmon','ESM1.5','area_fraction','map_land_ESM1.5.csv');
INSERT INTO mapping VALUES('cropFracC3','fld_s03i317 fld_s03i395','extract_tilefrac(var[0],9,landfrac=var[1],lev=''typec3crop'')','1','time pseudo_level_1 lat lon','longitude latitude time typec3crop','mon','land','area: mean where land over all_area_types time: mean','','CMIP6_Emon','CM2','area_fraction','map_land_CM2.csv');
Expand Down Expand Up @@ -2566,7 +2566,7 @@ INSERT INTO mapping VALUES('intvaw','fld_s30i429','','kg m-1 s-1','time lat lon'
INSERT INTO mapping VALUES('landCoverFrac','fld_s03i317 fld_s03i395','calc_landcover(var, ''cable'')','1','time pseudo_level_1 lat lon','longitude latitude vegtype time','mon','land','area: time: mean','','CMIP6_Lmon','CM2','SURFACE TILE FRACTIONS','map_land_CM2.csv');
INSERT INTO mapping VALUES('landCoverFrac','fld_s03i317 fld_s03i395','calc_landcover(var, ''cable'')','1','time pseudo_level_1 lat lon','longitude latitude vegtype time','mon','land','area: time: mean','','CMIP6_Lmon','ESM1.5','SURFACE TILE FRACTIONS','map_land_ESM1.5.csv');
INSERT INTO mapping VALUES('lmask','fld_s00i030','var[0].isel(time=0).astype(int)','%','time lat lon','longitude latitude','mon','land','area: time: mean','','AUS2200_fx','AM3','land_binary_mask','map_land_AM3.csv');
INSERT INTO mapping VALUES('lmask','fld_s00i030','var[0].isel(time=0).astype(int)','1','time_1 lat lon','longitude latitude','1hrPt','land','area: time: point','','AUS2200_fx','AUS2200','land_binary_mask','map_AUS2200.csv');
INSERT INTO mapping VALUES('lmask','fld_s00i030','var[0].isel(time=0).astype(int)','1','time_1 lat lon','longitude latitude','fx','land','area: time: point','','AUS2200_fx','AUS2200','land_binary_mask','map_AUS2200.csv');
INSERT INTO mapping VALUES('lmask','fld_s00i030','var[0].isel(time=0).astype(int)','1','time lat lon','longitude latitude','mon','land','area: time: point','','AUS2200_fx','CM2','land_binary_mask','map_land_CM2.csv');
INSERT INTO mapping VALUES('lmask','fld_s00i030','var[0].isel(time=0).astype(int)','1','time lat lon','longitude latitude','mon','land','area: time: point','','AUS2200_fx','ESM1.5','land_binary_mask','map_land_ESM1.5.csv');
INSERT INTO mapping VALUES('lwp','fld_s30i405','','kg m-2','time lat lon','longitude latitude time1','10minPt','atmos','area: time: point','','AUS2200_A10min','AUS2200','atmosphere_cloud_liquid_water_content','map_AUS2200.csv');
Expand Down Expand Up @@ -2684,7 +2684,7 @@ INSERT INTO mapping VALUES('omldamax','hblt_max','','m','time yt_ocean xt_ocean'
INSERT INTO mapping VALUES('omldamax','hblt_max','','m','time yt_ocean xt_ocean','longitude latitude time','mon','ocean','area: time: max','','CM2_mon','ESM1.5','ocean_mixed_layer_thickness_defined_by_mixing_scheme','map_ocean_ESM1.5.csv');
INSERT INTO mapping VALUES('omldamax','hblt_max','','m','time yt_ocean xt_ocean','longitude latitude time','mon','ocean','area: time: max','','CM2_mon','OM2','ocean_mixed_layer_thickness_defined_by_mixing_scheme','map_ocean_OM2.csv');
INSERT INTO mapping VALUES('orog','fld_s00i033','var[0].isel(time=0)','m','time lat lon','longitude latitude','mon','land','area: time: mean','','CMIP6_fx','AM3','surface_altitude','map_land_AM3.csv');
INSERT INTO mapping VALUES('orog','fld_s00i033','var[0].isel(time=0)','m','time_1 lat lon','longitude latitude','1hrPt','land','area: time: point','','CMIP6_fx','AUS2200','surface_altitude','map_AUS2200.csv');
INSERT INTO mapping VALUES('orog','fld_s00i033','var[0].isel(time=0)','m','time_1 lat lon','longitude latitude','fx','land','area: time: point','','CMIP6_fx','AUS2200','surface_altitude','map_AUS2200.csv');
INSERT INTO mapping VALUES('orog','fld_s00i033','var[0].isel(time=0)','m','time lat lon','longitude latitude','mon','land','area: mean','','CMIP6_fx','CM2','surface_altitude','map_land_CM2.csv');
INSERT INTO mapping VALUES('orog','fld_s00i033','var[0].isel(time=0)','m','time lat lon','longitude latitude','mon','land','area: mean','','CMIP6_fx','ESM1.5','surface_altitude','map_land_ESM1.5.csv');
INSERT INTO mapping VALUES('orog','surface_altitude','','m','time lat lon','longitude latitude','mon','land','area: time: mean','','CMIP6_fx','CM2','surface_altitude','map_land_CM2.csv');
Expand Down
3 changes: 2 additions & 1 deletion src/mopper/setup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ def add_files(ctx, cursor, opts, mp):
update = ctx.obj['update']
exp_start = opts['exp_start']
exp_end = opts['exp_end']
print("I am here")
# only used in cmip mode
if mp['years'] != 'all' and ctx.obj['dreq_years']:
exp_start, exp_end = fix_years(mp['years'], exp_start[:4], exp_end[:4])
Expand All @@ -649,6 +650,7 @@ def add_files(ctx, cursor, opts, mp):
# set half and full time step for each frequency
fname = import_files('mopdata').joinpath('tstep_delta.yaml')
tstep_dict = read_yaml(fname)['tstep_dict']
tstep_dict['fx'] = tstep_dict['day']
start = datetime.strptime(str(exp_start), '%Y%m%dT%H%M')
finish = datetime.strptime(str(exp_end), '%Y%m%dT%H%M')
frq = opts['frequency']
Expand All @@ -664,7 +666,6 @@ def add_files(ctx, cursor, opts, mp):
#loop over times
if frq == 'fx':
finish = start + relativedelta(days=1)
tstep_dict['fx'] = tstep_dict['day']
while (start < finish):
opts, newtime = define_file(opts, start, finish, delta,
tstep, half_tstep)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_setup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,5 @@ def test_define_file():
opts, newtime = define_file({'timeshot':'mean', 'frequency': 'mon'},
st, fin, delta, tstep, half_tstep)
assert newtime == datetime.strptime('20230701T0000', frm)

# see issue 197 when defining tests for add_files function

0 comments on commit 07a136a

Please sign in to comment.