Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Mapping RCP Lambert Conformal


Code:
I have been going back and forth with CISL help, and they directed me to this site.<br /><br />I am trying to map data from the CESM RCP 8.5 simulations. I couldn't find out whether or not the
data are on a native grid for Lambert Conformal, so I am assuming not. To get NCL to read in the
lat and lon correctly, I found the code on NCL's website:

; open file and read in data
;*******************************************
  f    = addfile ("pre.8912.mon.nc", "r")
  P    = f->pre
  LAT2D= f->lat
  LON2D= f->lon
;********************************************
;reorder arrays
;********************************************
  p = P(time|:,ycoord|:,xcoord|:)
  lon2d=LON2D(ycoord|:,xcoord|:)
  lat2d=LAT2D(ycoord|:,xcoord|:)
;********************************************

I am not sure what to use for ycoord and xcoord. I printed the variables and included screen shots
of lat and lon.
I received this rersponse:
Code:
Hi Brandi,

From your screenshots, it looks like you have a rectilinear grid, which is relatively easy to plot.
A rectilinear grid is one that can be represented by one-dimensional coordinate arrays.

I agree with you that your data is probably not on a native lambert conformal map.

If you want to put it on a Lambert Conformal, you will need to set  the two corners of your grid,
and set the two parallels and meridian.

See the sample script, which allows you to set LAMBERT_CONFORMAL to False if you want the default
cylindrical equidistant map.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"  
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"  
begin
  f    = addfile ("myfile.nc", "r")
  x    = f->x

  wks  = gsn_open_wks ("ps", "lcnative")          ; open workstation
  
  res                   = True               ; plot mods desired
  res@cnFillOn          = True               ; color fill  
  res@gsnAddCyclic      = False              ; if regional data

  LAMBERT_CONFORMAL = True      ; Use a lambert conformal map

  if(LAMBERT_CONFORMAL) then
    res@mpProjection      = "LambertConformal"
    res@mpLimitMode       = "Corners"            ; choose range of map
    res@mpLeftCornerLatF  = min(x&lat)    ; change as necessary
    res@mpLeftCornerLonF  = min(x&lon)    ; change as necessary
    res@mpRightCornerLatF = max(x&lat)    ; change as necessary
    res@mpRightCornerLonF = max(x&lon)    ; change as necessary
    
    res@mpLambertParallel1F = 30.    ; change as necessary
    res@mpLambertParallel2F = 55.    ; change as necessary
    res@mpLambertMeridianF  = 45.    ; change as necessary
  else
    res@mpMinLatF = min(x&lat)    ; change as necessary
    res@mpMinLonF = min(x&lon)    ; change as necessary
    res@mpMaxLatF = max(x&lat)    ; change as necessary
    res@mpMaxLonF = max(x&lon)    ; change as necessary
  end if  

  plot = gsn_csm_contour_map(wks,x,res)
  
end
I am still having issues:I am a little confused between the example script that NCL gives and the script that you gave me.  This is my code: load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" begin   fname = addfile ("b40.rcp8_5.1deg.007.cam2.h0.2020-07.nc", "r") ; read in file from path   t = fname ->T   tlat1 = 60.0  tlat2 = 30.0  clon  = -98.5   wks = gsn_open_wks("ps","RCP8.5_T_2020_test")   res  = True  res@cnFillOn                    = True ; fills in contours  res@cnLinesOn                   = False ; don't draw contour lines  res@cnLineLabelsOn              = False ; don't label contours   res@mpProjection                = "LambertConformal"  res@mpLambertParallel1F         = tlat1  res@mpLambertParallel2F         = tlat2  res@mpLambertMeridianF          = clon     res@mpLimitMode                 = "Corners"  res@mpLeftCornerLatF            = min(T&lon)  res@mpLeftCornerLonF            = min(T&lon)  res@mpRightCornerLatF           = max(T&lat)  res@mpRightCornerLonF           = max(T&lat)    tfDoNDCOverlay = True ; Draw the map    map = gsn_csm_contour_map(wks,T,res)  end  I'm not sure what NCL is wanting for the red area. In order for me to use lat and lon as variables, I thought they had to be read in as per the example script here: https://www.ncl.ucar.edu/Applications/Scripts/lcnative_1.ncl
In that example, it looks like they are reading in the one-dimensional lat and lon variables and converting them to 2-dimensional variables lat2d and lon2d, which are then used to define the corners.
 

hannay

Cecile Hannay
AMWG Liaison
Staff member
This is an ncl question.Please post to relevant forums described at:http://www.ncl.ucar.edu/Support/email_lists.shtml
 
Top