[ncl-talk] ESMF regridding

Chathurika chatu at scsio.ac.cn
Thu Mar 25 01:53:37 MDT 2021


Dear Dennis,




Many many thanks for your reply. Can we keep the time step in the following ESMF functions? Because I get the 'error' which is 




'fatal:Eq: Dimension size, for dimension number 0, of operands does not match, can't continue

fatal:["Execute.c":8637]:Execute: Error occurred at or near line 1623 in file $NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl'




The code which I used;




  diri = "./"
   fili = systemfunc("cd "+diri+" ; ls zos_*.nc")
   nfili= dimsizes(fili)
   print("nfili="+nfili)


   f    = addfiles(diri+fili,"r")
   ListSetType (f, "cat")  
   print(str_join(getfilevarnames(f[0]),", "))


   zos1= f[29:32]->zos(:,:,:)
   printVarSummary(zos1)


  time = f[29:32]->time(:)
  T = cd_calendar(time, -1)
  printVarSummary(T)
  printMinMax(T, False)




;---Interpolation methods


;---Output (and input) files
    srcGridName  = "CMIP5_SCRIP.nc"
    dstGridName  = "World1deg_SCRIP.nc"
    wgtFile      = "CMIP5_2_World_bilinear.nc"


;---Get data and lat/lon grid from CMIP5 Grid


    cmip5_lat2d = f[13]->latitude
    cmip5_lon2d = f[13]->longitude
    latlon_dims = dimsizes(cmip5_lon2d)




;----------------------------------------------------------------------
; Convert CMIP5 to SCRIP file.
;----------------------------------------------------------------------
      Opt                = True
      Opt at Mask2D         = where(.not.ismissing(zos1),1,0)
      Opt at GridCornerLat  = f[13]->vertices_latitude
      Opt at GridCornerLon  = f[13]->vertices_longitude
      Opt at PrintTimings   = True
      Opt at ForceOverwrite = True
      Opt at Debug          = True


      curvilinear_to_SCRIP(srcGridName,cmip5_lat2d,cmip5_lon2d,Opt)


;---Clean up
      delete(Opt)




;----------------------------------------------------------------------
; Convert 1 degree world grid to SCRIP file
;----------------------------------------------------------------------
      Opt                = True
      Opt at ForceOverwrite = True
      Opt at LLCorner       = (/-90.00d, -180.00d /)
      Opt at URCorner       = (/ 90.00d, 180.00d /) 
      ;Opt at Title          = "World Grid 1-degree Resolution"
      Opt at PrintTimings   = True
      Opt at Debug          = True


      latlon_to_SCRIP(dstGridName,"1x1",Opt)


;---Clean up
      delete(Opt)
 


;----------------------------------------------------------------------
; Loop across each method and generate interpolation weights for 
; CMIP5 Grid to World Grid    
;----------------------------------------------------------------------
        Opt                      = True
        Opt at ForceOverwrite       = True
        Opt at SrcESMF              = False
        Opt at DstESMF              = False
        Opt at InterpMethod         = "bilinear"
        Opt at PrintTimings         = True




        ESMF_regrid_gen_weights(srcGridName, dstGridName, wgtFile, Opt)


;---Clean up
        delete(Opt)




;----------------------------------------------------------------------
; Interpolate data from CMIP5 to World 1-degree grid.
;----------------------------------------------------------------------
      Opt                = True
      Opt at PrintTimings   = True
      Opt at Debug          = True


      zos1_regrid = ESMF_regrid_with_weights(zos1,wgtFile,Opt)


      printVarSummary(var_regrid)
;----------------------------------------------------------------------
delete(Opt)




The script works fine when I input the time mean (zos(:,:)). I reorder the dimensions (zos(lat|:,lon|:,time|:). None of this works and I am not very good at this. So please help me.




Thank you very much and best regards,

Chathu

-----Original Messages-----
From:"Dennis Shea" <shea at ucar.edu>
Sent Time:2021-03-25 02:57:04 (Thursday)
To: Chathurika <chatu at scsio.ac.cn>
Cc: "Rashed Mahmood" <rashidcomsis at gmail.com>, ncl-talk <ncl-talk at mailman.ucar.edu>
Subject: Re: [ncl-talk] ESMF regridding


Let variable:  R(time,latR,lonR)



If you input a variable with SOURCE dimensions HR(time, lat_source, lon_source) and specify your destination as latR,lonR

via ESMF you will get LR (time, latR, lonR)



DIFF = LR-R    ; DIFF(time,latR,lonR)







On Wed, Mar 24, 2021 at 12:38 PM Chathurika via ncl-talk <ncl-talk at mailman.ucar.edu> wrote:


Dear Rashed

Many thanks for you email. I know this way. But what I want is regrid both dataset into one grid without removing the time dimension from it. To get the differences of datasets (HR-LR), I need to regrid them into the same dimension. Using the method you mentioned, I can plot the map. But how can I get the difference (HR-LR)?




Thanks once again and best,

Chathu


-----Original Messages-----
From:"Rashed Mahmood" <rashidcomsis at gmail.com>
Sent Time:2021-03-25 01:38:37 (Thursday)
To: Chathurika <chatu at scsio.ac.cn>
Cc:ncl-talk at mailman.ucar.edu
Subject: Re: [ncl-talk] ESMF regridding


Hi Chatu,


ESMF regridding works fine for 3 dimensional data. What makes you think it does not?



Likely you would need to attach the 2d coordinate arrays with the variables, e.g.:


varb1 at lat2d  = infile1->latitude      

varb1 at lon2d = infile1->longitude


varb2 at lat2d  = infile2->latitude      

varb2 at lon2d = infile2->longitude


If this does not work, then share a full script (and any error messages you get).


HTH
Rashed









On Wed, Mar 24, 2021 at 4:28 PM Chathurika via ncl-talk <ncl-talk at mailman.ucar.edu> wrote:


Dear All,




Thank you so much for reading my email and helping me out to solve this issue.




I want to perform the significance test (ttest) over time dimension for the differences of two datasets which have lat[:,:] and lon[:,:] (two dimensional, like WRF). 




 differences = (high resolution - low resolution). 




However, the dimensions of lat and lon are not same. The variable summary is;




Low resolution:

Type: float

Total Size: 54067200 bytes

            13516800 values

Number of Dimensions: 3

Dimensions and sizes: [time | 240] x [j | 220] x [i | 256]

Coordinates: 

            time: [52975.5..60249.5]

            j: [0..219]

            i: [0..255]

Number Of Attributes: 11

  standard_name : sea_surface_height_above_geoid

  long_name : Sea Surface Height Above Geoid

  comment : This is the dynamic sea level, so should have zero global area mean. It should not include inverse barometer depressions from sea ice.

  units : m

  original_name : zos

  cell_methods : area: mean where sea time: mean

  cell_measures : area: areacello

  history : 2019-09-04T15:31:31Z altered by CMOR: replaced missing value flag (-9e+33) and corresponding data with standard missing value (1e+20).

  missing_value : 1e+20

  _FillValue : 1e+20

  coordinates : latitude longitude







High resolution:




Type: float

Total Size: 311047680 bytes

            77761920 values

Number of Dimensions: 3

Dimensions and sizes: [time | 240] x [j | 404] x [i | 802]

Coordinates: 

            time: [52975.5..60249.5]

            j: [0..403]

            i: [0..801]

Number Of Attributes: 11

  standard_name : sea_surface_height_above_geoid

  long_name : Sea Surface Height Above Geoid

  comment : This is the dynamic sea level, so should have zero global area mean. It should not include inverse barometer depressions from sea ice.

  units : m

  original_name : zos

  cell_methods : area: mean where sea time: mean

  cell_measures : area: areacello

  history : 2019-08-25T07:38:10Z altered by CMOR: replaced missing value flag (-9e+33) and corresponding data with standard missing value (1e+20).

  missing_value : 1e+20

  _FillValue : 1e+20

  coordinates : latitude longitude




*latitude and longitude have two dimensions.







I cannot do ESMF regridding as per it is not allowed to use the all three dimensions (time, lat, lon). I am little confused here, How can I use ESMF regridding and keep the time dimension also. If so, after regridding, I can perform the ttest for the resolution difference.




Please help me and Many many thanks.




Best regards,

Chathu





Wickramage Chathurika Hemamali
Msc in Physical Oceanography
State Key Laboratory of Tropical Oceanography
South China Sea Institute of Oceanology
University of Chinese Academy of Science
China


Specialized in Oceanography and Marine Geology (Bachelor)
University of Ruhuna
Matara
Sri Lanka


Email : wickramagechathurika at rocketmail.com
chatu at scsio.ac.cn
_______________________________________________
ncl-talk mailing list
ncl-talk at mailman.ucar.edu
List instructions, subscriber options, unsubscribe:
https://mailman.ucar.edu/mailman/listinfo/ncl-talk






Wickramage Chathurika Hemamali
Msc in Physical Oceanography
State Key Laboratory of Tropical Oceanography
South China Sea Institute of Oceanology
University of Chinese Academy of Science
China


Specialized in Oceanography and Marine Geology (Bachelor)
University of Ruhuna
Matara
Sri Lanka


Email : wickramagechathurika at rocketmail.com
chatu at scsio.ac.cn
_______________________________________________
ncl-talk mailing list
ncl-talk at mailman.ucar.edu
List instructions, subscriber options, unsubscribe:
https://mailman.ucar.edu/mailman/listinfo/ncl-talk






Wickramage Chathurika Hemamali
Msc in Physical Oceanography
State Key Laboratory of Tropical Oceanography
South China Sea Institute of Oceanology
University of Chinese Academy of Science
China


Specialized in Oceanography and Marine Geology (Bachelor)
University of Ruhuna
Matara
Sri Lanka


Email : wickramagechathurika at rocketmail.com
chatu at scsio.ac.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210325/273217e3/attachment.html>


More information about the ncl-talk mailing list