NOAA-GFDL / fre-cli

Python-based command line interface for FRE (FMS Runtime Environment) to compile and run FMS-based models and post-process their output.
GNU Lesser General Public License v3.0
3 stars 11 forks source link

notes and extracted hard-coding of `fre/cmor/cmor_mixer.py` #232

Open ilaflott opened 3 weeks ago

ilaflott commented 3 weeks ago

as of this commit, some of the notes/details you see below are actually being used by being defined in comment form, if you will....

# ------ \start assumptions / potential future configuration thingies.                                                                                              
# GLOBAL hardcoded assumption: netcdf files always have an ending of '.nc'                                                                                          
#                              many implicit assumptions regarding the presence of metadata in the input netcdf file name                                           
#                                  e.g. datetime, variable name, name_of_set are all assumed to be at particular spots                                              
#                              utf8 encoding                                                                                                                        
#                              MINOR: opening netcdf files in append or write or read                                                                               
#                              MINOR: key names in certain input configuration files- these are tightly controlled                                                  
#                                                                                                                                                                   
# for check_dataset_for_ocean_grids:                                                                                                                                
#                                    input reading/checking hardcode - dataset doesn't have a variable named 'xh'                                                   
# for get_vertical_dimension:                                                                                                                                       
#                             input reading/checking hardcode - dataset has dimension/axis name 'Z'                                                                 
# for create_tmp_dir:                                                                                                                                               
#                     input reading/checking hardcode - check output directory for specific drives local2, work, net                                                
#                     output moving/writing hardcode - tmpdir name is 'tmp' if condition met                                                                        
#                                                                                                                                                                   
# for rewrite_netcdf_file_var:                                                                                                                                      
#                              input reading/checking hardcode - dimensions named 'lat', 'lon', 'time'                                                              
#                              input reading/checking hardcode - "bounds" for above, named 'lat_bnds', 'lon_bnds', 'time_bnds'                                      
#                              input reading/checking hardcode - check that var_dim is 3 or 4                                                                       
#                              input reading/checking hardcode - check that var_dim is 3 --> simple 3 dim subcase                                                   
#                              input reading/checking hardcode - if var_dim is 4, vert_dim must be one of the following:                                            
#                                                                "plev30", "plev19", "plev8","height2m", "level", "lev", "levhalf"                                  
#                              input reading/checking hardcode -     then subcases are relevant as follows:                                                         
#                                                                    if   vert_dim in ["plev30", "plev19", "plev8", "height2m"] --> SUBCASE                         
#                                                                    elif vert_dim in ["level", "lev", "levhalf"] --> DISTINCT SUBCASE                              
#                                                                        pressure input file is tagged with 'ps' potentially nearby                                 
#                                                                        sub_sub_case --> if vert_dim is lev_half                                                   
#                                                                            input ds has zfactor values as 'ap_bnds', 'b_bnds'                                     
#                              output moving/writing hardcode -              output zfactors have names "ap_half", "b_half",                                        
#                                                                            output vertical level axis name "alternate_hybrid_sigma_half"                          
#                                                                        sub_sub_case --> else                                                                      
#                                                                            input ds has zfactor values as 'ap' and 'b', and zfactor bnds as 'ap_bnds', 'b_bnds'   
#                              output moving/writing hardcode -              output zfactors have names "ap", "b",                                                  
#                                                                            output vertical level axis name "alternate_hybrid_sigma"                               
#                              output moving/writing hardcode -          output interpolated pressures have name "ps", units "Pa"                                   
#                              output moving/writing hardcode -  cmor setup parameters                                                                              
#                              output moving/writing hardcode -  lat/lon axies named "latitude"/"longitude" with units "degrees_N" "degrees_E"                      
#                                                                                                                                                                   
# for cmorize_target_var_files:                                                                                                                                     
#                               input reading/checking hardcode - pressure input file is tagged with 'ps' potentially nearby                                        
#                               output moving/writing hardcode -  pressure out file is named with 'ps'                                                              
#                                                                                                                                                                   

in const form

# ----- \start consts                                                                                                                                               
DEBUG_MODE_RUN_ONE = True                                                                                                                                           

#                                                                                                                                                                   
INPUT_READ_PS_FILE_VAR_NAME = 'ps'                                                                                                                                  
INPUT_READDIR_NAME_CHECKS = [ [ 'contains', '/work'],                                                                                                               
                              ['contains', '/net'],                                                                                                                 
                              ['equal', '/local2']  ]                                                                                                               

#                                                                                                                                                                   
OUTPUT_TEMP_DIR_NAME = 'tmp'                                                                                                                                        

#                                                                                                                                                                   
INPUT_READ_OCEAN_GRID_VAR_NAME = 'xh'                                                                                                                               
INPUT_READ_Z_AXIS_NAME = 'Z'                                                                                                                                        

#                                                                                                                                                                   
INPUT_READ_LAT_DIM = 'lat'                                                                                                                                          
INPUT_READ_LAT_BNDS = 'lat_bnds'                                                                                                                                    
INPUT_READ_LON_DIM = 'lon'                                                                                                                                          
INPUT_READ_LON_BNDS = 'lon_bnds'                                                                                                                                    
INPUT_READ_TIME_DIM = 'time'                                                                                                                                        
INPUT_READ_TIME_BNDS = 'time_bnds'                                                                                                                                  

#                                                                                                                                                                   
INPUT_ACCEPT_VAR_DIMS = [3,4]                                                                                                                                       
INPUT_ACCEPT_VERT_DIMS = ["plev30", "plev19", "plev8","height2m", "level", "lev", "levhalf"]                                                                        

# ----                                                                                                                                                              
#INPUT_SUBCASE1_VAR_VERT_DIMS = { "4": [ "plev30", "plev19", "plev8", "height2m" ] }                                                                                

# ----                                                                                                                                                              
INPUT_SUBCASE2_VAR_VERT_DIMS = { "4": [ "level", "lev", "levhalf" ] }                                                                                               
#-                                                                                                                                                                  
OUTPUT_SUBCASE2_PS_VAR_NAME = 'ps'                                                                                                                                  
OUTPUT_SUBCASE2_PS_VAR_UNIT = 'Pa'                                                                                                                                  

# --- ---                                                                                                                                                           
INPUT_SUBCASE2_0_VAR_VERT_DIMS = { "4": [ "levhalf" ] }                                                                                                             
INPUT_SUBCASE2_0_ZFACT_VALS = ['ap_bnds','b_bnds']                                                                                                                  
#-                                                                                                                                                                  
OUTPUT_SUBCASE2_0_ZFACT_VAL_NAMES = ['ap_half','b_half']                                                                                                            
OUTPUT_SUBCASE2_0_VERT_LVL_NAME = 'altername_hybrid_sigma_half'                                                                                                     

# --- ---                                                                                                                                                           
INPUT_SUBCASE2_1_VAR_VERT_DIMS = { "4": [ "level", "lev" ] }                                                                                                        
INPUT_SUBCASE2_1_ZFACT_VALS = ['ap','b']                                                                                                                            
INPUT_SUBCASE2_1_ZFACT_BNDS = ['ap_bnds','b_bnds']                                                                                                                  
#-                                                                                                                                                                  
OUTPUT_SUBCASE2_0_ZFACT_VAL_NAMES = ['ap','b']                                                                                                                      
OUTPUT_SUBCASE2_0_VERT_LVL_NAME = 'altername_hybrid_sigma'         
ceblanton commented 2 weeks ago

Interesting to see all the conventions together. Some of them are CF conventions, such as the units of latitude, that can be relied on in this world of ours. Others are de-facto conventions that could be rephrased if needed (but it's not really needed), lat_bnds, etc. The remainders after those two are CMIP7-particular conventions.