[ncl-talk] converting generic POP grid to regular LatLon grid

Sri nandini bax8609 at uni-hamburg.de
Fri Nov 5 07:33:15 MDT 2021


Hello dear ncl-users,

Can someone advice me whether the following method is correct?

I have an initial CESM POP file with lat and lon in generic grid which 
looks like the below:

netcdf zos_Omon_CESM1-CAM5_historical_rcp85_r38i1p1_192001-210012 {
dimensions:
     time = UNLIMITED ; // (2172 currently)
     i = 320 ;
     j = 384 ;
variables:
     double time(time) ;
         time:standard_name = "time" ;
         time:long_name = "time" ;
         time:units = "days since 0000-01-01 00:00:00" ;
         time:calendar = "365_day" ;
         time:axis = "T" ;
     int i(i) ;
         i:long_name = "cell index along first dimension" ;
         i:units = "1" ;
         i:axis = "X" ;
     int j(j) ;
         j:long_name = "cell index along second dimension" ;
         j:units = "1" ;
         j:axis = "Y" ;
     float lat(j, i) ;
         lat:standard_name = "latitude" ;
         lat:long_name = "latitude coordinate" ;
         lat:units = "degrees_north" ;
     float lon(j, i) ;
         lon:standard_name = "longitude" ;
         lon:long_name = "longitude coordinate" ;
         lon:units = "degrees_east" ;
     float zos(time, j, i) ;
         zos:standard_name = "sea_surface_height_above_geoid" ;
         zos:long_name = "sea_surface_height_above_geoid" ;
         zos:units = "m" ;
         zos:_FillValue = 1.e+20f ;
         zos:missing_value = 1.e+20f ;
         zos:comment = "Created using NCL code" ;
         zos:cell_methods = "time: mean (interval: 1 month)" ;
         zos:history = "SSH/100" ;
         zos:original_units = "cm" ;
         zos:original_name = "SSH" ;

I tried several methods to convert this into a regular LatLon grid, 
finally using the method from here: 
https://www.ncl.ucar.edu/Applications/pop2lat.shtml

I used the pop2lat_1.ncl 
<https://www.ncl.ucar.edu/Applications/Scripts/pop2lat_1.ncl>: to 
interpolate with this POP weights file: 
map_gx1v6_to_1x1d_bilin_da_100716.nc.

Attached here is the script i modified as well as the plot. I do not get 
any error, but i wish to know if this was the correct method? There are 
many POP weights available and i choose this one.

Best

Sri

-- 
Dr. Sri Nandini-Weiss

Center for Earth System Research and Sustainability (CEN)
Cluster of Excellence 'Climate, Climatic Change, and Society' (CLICCS)

Universität Hamburg
Institute of Oceanography
Bundesstraße 53
20146 Hamburg
Germany
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20211105/61773867/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pop2lat.png
Type: image/png
Size: 143445 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20211105/61773867/attachment.png>
-------------- next part --------------
;************************************************
; pop2lat_1.ncl
;************************************************
;
; These files are loaded by default in NCL V6.2.0 and newer
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"   
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"    
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"  
;
; This file still needs to be loaded manually
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/popRemap.ncl"  
;************************************************
begin
  in  = addfile("zos_Omon_CESM1-CAM5_historical_rcp85_r19i1p1_192001-210012.nc","r")
  ice = in->zos
  printVarSummary(ice)

  ice=ice/100
  ice1=dim_avg_n_Wrap(ice,0)
  printVarSummary(ice1)

;************************************************
; convert pop to a 1x1 degree grid
;************************************************
  remap = PopLatLon(ice1,"gx1v6","1x1d","bilin","da","100716")
  printVarSummary(remap)

;save this as netcdf and later loop through 40files
    system("/bin/rm -f zos_Omon_CESM1-CAM5_historical_rcp85_r19i1p1_regridded.nc")   ; remove any pre-existing file
    outfile = addfile("zos_Omon_CESM1-CAM5_historical_rcp85_r19i1p1_regridded.nc","c")
    outfile->zos = remap
;************************************************
; create plots
;************************************************
  wks = gsn_open_wks("png","pop2lat")           ; send graphics to PNG file
  cmap = read_colormap_file("WhBlGrYeRe")       ; read colormap data
  
  res                      = True
  ;res at gsnPolar             = "NH"               ; choose hemisphere
  ;res at gsnDraw             = False           ; don't draw
  ;res at gsnFrame            = False           ; don't advance frame
  ;res at cnInfoLabelOn       = False           ; turn off cn info label
  res at cnFillOn            = True            ; turn on color
  res at mpDataBaseVersion   = "MediumRes"
  res at cnLinesOn           = False
  
  res at mpProjection         = "Robinson"
 res at mpMinLonF            =   0
  res at mpMaxLonF            = 360
  res at mpCenterLonF         = 180               
  res at mpOutlineOn          = True
  res at mpPerimOn            = False
  res at cnFillOn             = True               ; turn on color
;  res at cnFillPalette        = cmap(0:95,:)       ; set color map
  res at cnLinesOn            = False              ; no contour lines
  
 ; res at mpLandFillColor      = "grey"             ; color of land
  ;res at mpMinLatF            = 50                 ; adjust map limit
  
    res at lbBoxEndCapStyle     = "TriangleBothEnds"              
  res at tiMainFont           = "Helvetica"                     ; Font for title
  res at tiXAxisFont          = "Helvetica"                     ; Font for X axis label
  res at tiYAxisFont          = "Helvetica"                     ; Font for Y axis label
  res at gsnMaximize          = True              ; large format in landscape
  res at mpFillDrawOrder       = "PostDraw"       ; draw map fill last
  res at gsnCenterString      = " "
  res at gsnLeftString        = " "
  res at gsnRightString       = " "

  res at cnLevelSelectionMode = "ManualLevels"     ; set manual contour levels
  ;res at cnMinLevelValF       =  0.                ; set min contour level
  ;res at cnMaxLevelValF       =  5.                ; set max contour level
  ;res at cnLevelSpacingF      =  0.5               ; set contour spacing
    
  res at tiMainString        = "gx1v3 to 1x1d"
  
; because this is ice data, which has a gap in the tropics, we need to
; explicitly pass the range of the data to plot.  Since we are coloring 
; the vectors, this range should also match the MinLatF above, since the
; range for the colors is chosen over the full data passed, and not the
; map limits.

  plot = gsn_csm_contour_map(wks,remap,res)
   
end


More information about the ncl-talk mailing list