Changeset 6244 for TOOLS/MOSAIX
- Timestamp:
- 09/20/22 11:40:22 (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TOOLS/MOSAIX/RunoffWeights.py
r6190 r6244 163 163 atm_perio = 0 164 164 atm_grid_pmask = atm_grid_imask 165 166 165 167 atm_address = np.arange(atm_jpj*atm_jpi) 166 168 … … 177 179 oce_grid_dims = gridFile['torc.lat'][:].shape 178 180 179 if oce_perio == 0 : 180 if oce_jpi == 182 : oce_perio = 4 # ORCA 2 181 if oce_jpi == 362 : oce_perio = 6 # ORCA 1 182 if oce_jpi == 1442 : oce_perio = 6 # ORCA 025 183 181 # imask : includes periodicity point 182 # pmask : exclude periodicity points 183 184 #if oce_perio == 0 : 185 # if oce_jpi == 182 : oce_perio = 4 # ORCA 2 186 # if oce_jpi == 362 : oce_perio = 6 # ORCA 1 187 # if oce_jpi == 1442 : oce_perio = 6 # ORCA 025 188 oce_preio = nemo.__guessNperio__ (oce_jpj, oce_jpi, nperio=oce_perio) 189 184 190 print ("Oce NPERIO parameter : {:}".format(oce_perio)) 185 oce_grid_pmask = nemo.lbc_mask (np.reshape(oce_grid_imask.values, (oce_jpj,oce_jpi)), nperio=oce_perio, cd_type='T', sval=0).ravel() 191 oce_grid_imask = nemo.lbc (np.reshape(oce_grid_imask.values, (oce_jpj,oce_jpi)), nperio=oce_perio, cd_type='T' ).ravel() 192 oce_grid_pmask = nemo.lbc_mask (np.reshape(oce_grid_imask , (oce_jpj,oce_jpi)), nperio=oce_perio, cd_type='T', sval=0).ravel() 186 193 oce_address = np.arange(oce_jpj*oce_jpi) 187 194 188 print ("Fill closed sea with image processing library") 189 oce_grid_imask2D = np.reshape(oce_grid_pmask,(oce_jpj,oce_jpi)) 190 oce_grid_imask2D = nemo.lbc_mask ( 1-ndimage.binary_fill_holes (1-nemo.lbc(oce_grid_imask2D, nperio=oce_perio, cd_type='T')), 191 nperio=oce_perio, cd_type='T', sval=0 ) 192 oce_grid_imask = oce_grid_imask2D.ravel() 195 print ("Fill closed seas with image processing library") 196 oce_grid_imask2D = np.reshape (oce_grid_imask, (oce_jpj,oce_jpi)) 197 oce_grid_imask2D = 1-nemo.fill_closed_seas (1-oce_grid_imask2D, nperio=oce_perio, cd_type='T') 198 #oce_grid_imask2D = nemo.lbc ( 1-ndimage.binary_fill_holes (1-nemo.lbc(oce_grid_imask2D, nperio=oce_perio, cd_type='T')), 199 # nperio=oce_perio, cd_type='T' ) 200 oce_grid_imask = oce_grid_imask2D.ravel () 201 193 202 ## 194 print ("Computes an ocean coastal band") 195 196 oceLand2D = np.reshape ( np.where (oce_grid_pmask < 0.5, True, False), (oce_jpj, oce_jpi) ) 197 oceOcean2D = np.reshape ( np.where (oce_grid_pmask > 0.5, True, False), (oce_jpj, oce_jpi) ) 203 print ("Computes an ocean coastal band with image processing library") 204 oceLand2D = np.reshape ( np.where (oce_grid_imask < 0.5, True, False), (oce_jpj, oce_jpi) ) 205 oceOcean2D = np.reshape ( np.where (oce_grid_imask > 0.5, True, False), (oce_jpj, oce_jpi) ) 198 206 199 207 NNocean = 1+2*oceCoastWidth 200 oceOceanFiltered2D = ndimage.uniform_filter (oceOcean2D.astype(float), size=NNocean)208 oceOceanFiltered2D = ndimage.uniform_filter (oceOcean2D.astype(float), size=NNocean) 201 209 oceCoast2D = np.where (oceOceanFiltered2D<(1.0-0.5/(NNocean**2)),True,False) & oceOcean2D 202 oceCoast2D = nemo.lbc_mask (np.reshape(oceCoast2D, (oce_jpj,oce_jpi)), nperio=oce_perio, cd_type='T').ravel()210 oceCoast2D = nemo.lbc_mask (np.reshape(oceCoast2D, (oce_jpj,oce_jpi)), nperio=oce_perio, cd_type='T', sval=0.).ravel() 203 211 204 212 oceOceanFiltered = oceOceanFiltered2D.ravel() … … 219 227 oceCoast_address = oce_address [oceCoast] 220 228 221 print ("Computes an atmosphere coastal band 229 print ("Computes an atmosphere coastal band" ) 222 230 atmLand = np.where (o2aFrac[:] < epsfrac , True, False) 223 231 atmLandFrac = np.where (o2aFrac[:] < zone-epsfrac , True, False) … … 262 270 if searchRadius > 0. : 263 271 print ("Loop on atmosphere coastal points") 264 for ja in np.arange (len(atmCoast_grid_pmask)) :272 for ja in np.arange (len(atmCoast_grid_pmask)) : 265 273 z_dist = geodist ( atmCoast_grid_center_lon[ja], atmCoast_grid_center_lat[ja], oceCoast_grid_center_lon, oceCoast_grid_center_lat) 266 274 z_mask = np.where (z_dist*ra < searchRadius, True, False) 267 num_links = int (z_mask.sum())275 num_links = int (z_mask.sum()) 268 276 if num_links == 0 : continue 269 277 z_area = oceCoast_grid_area[z_mask].sum().values … … 276 284 # 277 285 matrix_local = poids 278 atm_address_local = np.ones (num_links, dtype=np.int32 ) * atmCoast_address[ja]286 atm_address_local = np.ones (num_links, dtype=np.int32 ) * atmCoast_address[ja] 279 287 # Address on destination grid 280 oce_address_local = oceCoast_address [z_mask]288 oce_address_local = oceCoast_address [z_mask] 281 289 # Append to global arrays 282 290 remap_matrix = np.append ( remap_matrix, matrix_local )
Note: See TracChangeset
for help on using the changeset viewer.