Changeset 4089


Ignore:
Timestamp:
10/25/18 09:31:39 (4 years ago)
Author:
omamce
Message:

O.M. : add cases to check_conserv.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/MOSAIX/check_conserv.py

    r4086 r4089  
    3333 
    3434# Adding arguments 
    35 parser.add_argument ( '--file'     , help='Input file, e.g. dia_tICO40_to_teORCA1.2_1storder_false.nc', type=str, default='dia_tico_to_torc_1storder_false.nc' ) 
    36 parser.add_argument ( '--grids'    , help='grids file  ', type=str, default='grids.nc' ) 
    37 parser.add_argument ( '--areas'    , help='areas file  ', type=str, default='areas.nc' ) 
    38 parser.add_argument ( '--masks'    , help='masks file  ', type=str, default='masks.nc' ) 
    39 parser.add_argument ( '--fracs'    , help='fracs file  ', type=str, default=None ) 
    40 parser.add_argument ( '--guess'    , help='If set, build grids, areas and masks file name from the dia file name', action="store_true", default=False ) 
    41 parser.add_argument ( '--src_int'  , help='Source field is integrated'     , action="store_true" ) 
    42 parser.add_argument ( '--dst_int'  , help='Destination field is integrated', action="store_true" ) 
    43 parser.add_argument ( '--src_nofrac' , help='Do not apply frac on source'     , action="store_true" ) 
    44 parser.add_argument ( '--dst_nofrac' , help='Do not apply frac on destination', action="store_true" ) 
     35parser.add_argument ( '--file'      , help='Input file, e.g. dia_tICO40_to_teORCA1.2_1storder_false.nc', type=str, default='dia_tico_to_torc_1storder_false.nc' ) 
     36parser.add_argument ( '--grids'     , help='grids file', type=str, default='grids.nc' ) 
     37parser.add_argument ( '--areas'     , help='areas file', type=str, default='areas.nc' ) 
     38parser.add_argument ( '--masks'     , help='masks file', type=str, default='masks.nc' ) 
     39parser.add_argument ( '--fracs'     , help='fracs file', type=str, default=None ) 
     40parser.add_argument ( '--guess'     , help='If set, build grids, areas and masks file name from the dia file name', action="store_true", default=False ) 
     41parser.add_argument ( '--src_int'   , help='Source field is integrated'      , action="store_true" ) 
     42parser.add_argument ( '--dst_int'   , help='Destination field is integrated' , action="store_true" ) 
     43parser.add_argument ( '--src_nofrac', help='Do not apply frac on source'     , action="store_true" ) 
     44parser.add_argument ( '--dst_nofrac', help='Do not apply frac on destination', action="store_true" ) 
    4545 
    4646# Parse command line 
     
    113113 
    114114# 
    115 msk_src = np.float64(1.0) - f_masks ( grid_src + name_src + '.msk' ) 
    116 lon_src = f_grids ( grid_src + name_src + '.lon' ) 
    117 lat_src = f_grids ( grid_src + name_src + '.lat' ) 
    118 if myargs.dst_int : srf_src = np.ones ( (msk_src.shape), dtype=np.float64 ) 
    119 else              : srf_src = f_areas ( grid_src + name_src + '.srf' ) 
     115msk_src = np.float64(1.0) - f_masks ( grid_src + name_src + '.msk', squeeze=True ) 
     116lon_src = f_grids ( grid_src + name_src + '.lon', squeeze=True ) 
     117lat_src = f_grids ( grid_src + name_src + '.lat', squeeze=True ) 
     118if myargs.src_int : srf_src = np.ones ( (msk_src.shape), dtype=np.float64 ) 
     119else              : srf_src = f_areas ( grid_src + name_src + '.srf', squeeze=True ) 
    120120 
    121121# 
    122 msk_dst = np.float64(1.0) - f_masks ( grid_dst + name_dst + '.msk' ) 
    123 lon_dst = f_grids ( grid_dst + name_dst + '.lon' ) 
    124 lat_dst = f_grids ( grid_dst + name_dst + '.lat' ) 
     122msk_dst = np.float64(1.0) - f_masks ( grid_dst + name_dst + '.msk', squeeze=True ) 
     123lon_dst = f_grids ( grid_dst + name_dst + '.lon', squeeze=True ) 
     124lat_dst = f_grids ( grid_dst + name_dst + '.lat', squeeze=True ) 
    125125if myargs.dst_int : srf_dst = np.ones ( (msk_dst.shape), dtype=np.float64) 
    126126else              : srf_dst = f_areas ( grid_dst + name_dst + '.srf' ) 
     
    129129if name_src in ( 'ico', 'lmd' ) : 
    130130    if myargs.src_nofrac : frc_src = np.ones ( (msk_src.shape), dtype=np.float64) 
    131     else                 : frc_src = f_frac ( 'OceFrac' ) 
     131    else                 : frc_src = f_frac ( 'OceFrac', squeeze=True ) 
    132132if name_src == 'orc'     : frc_src = np.ones ( (msk_src.shape), dtype=np.float64) 
    133133if name_dst in ( 'ico', 'lmd' ) : 
    134134    if myargs.dst_nofrac : frc_dst = np.ones ( (msk_dst.shape), dtype=np.float64) 
    135     else                 : frc_dst = f_frac ( 'OceFrac' ) 
     135    else                 : frc_dst = f_frac ( 'OceFrac', squeeze=True ) 
    136136if name_dst == 'orc'     : frc_dst = np.ones ( (msk_dst.shape), dtype=np.float64) 
    137137 
    138138# Periodicity 
    139 nperio_src = 0 
    140 nperio_dst = 0 
     139nperio_src = 0 ; nperio_dst = 0 
    141140 
    142141if Name_src == 'ORCA2.3'  : nperio_src = 4 
     
    151150if Name_src in ('ORCA2.3', 'eORCA1.2', 'eORCA025') : msk_src = nemo.lbc_mask ( msk_src, nperio=nperio_src, cd_type=Grid_src ) 
    152151if Name_dst in ('ORCA2.3', 'eORCA1.2', 'eORCA025') : msk_dst = nemo.lbc_mask ( msk_dst, nperio=nperio_dst, cd_type=Grid_dst ) 
    153    
    154 #frc_atm = f_frac ('OceFrac')[0,:] * msk_atm 
    155 #frc_oce = np.float64(msk_oce) 
    156 #srf_atm = f_areas ('tico.srf') * frc_atm 
    157 #srf_oce = f_areas ('torc.srf') * frc_oce 
    158  
    159 area_src = np.sum (srf_src * msk_src * frc_src) 
    160 area_dst = np.sum (srf_dst * msk_dst * frc_dst) 
     152     
     153# Surfaces 
     154area_src = np.sum ( srf_src * msk_src * frc_src ) 
     155area_dst = np.sum ( srf_dst * msk_dst * frc_dst ) 
    161156 
    162157print ( Name_src ) 
Note: See TracChangeset for help on using the changeset viewer.