[ncl-talk] UTC to local time

Annie Seagram aseagram at sonomatech.com
Wed Aug 31 09:26:03 MDT 2016


I don't know about converting datetime information based on lat/lon location, but if you know what the timezone name is (e.g. PST) then you could use a date command line tool (type `man date` for help) and call it from your NCL script using `systemfunc`. A rough example:


begin

  DOUBLE_QUOTE = integertochar(34)
  tzin = "PST"

  datestr = "201211120811"
  dateinfo = str_split_by_length(datestr, (/ 4, 2, 2, 2, 2 /))

  yearstr = dateinfo(0)
  monthstr = dateinfo(1)
  daystr = dateinfo(2)
  hourstr = dateinfo(3)
  minutestr = dateinfo(4)

  dt = str_join((/ yearstr, monthstr, daystr /), "-") + " " + hourstr + ":" + minutestr + " " + tzin
  cmd = "TZ=UTC date --date=" + DOUBLE_QUOTE + dt + DOUBLE_QUOTE + " +%Y%m%d%H%M"
  datetime = systemfunc(cmd)

  print(datestr)
  print(datetime)

end


The printed output is:


Variable: datestr
Type: string
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
(0)     201211120811


Variable: datetime
Type: string
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes:   [1]
Coordinates:
(0)     201211121611


- annie

-----Original Message-----
From: ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] On Behalf Of ncl-talk-request at ucar.edu
Sent: Tuesday, August 30, 2016 9:29 PM
To: ncl-talk at ucar.edu
Subject: ncl-talk Digest, Vol 153, Issue 42

Send ncl-talk mailing list submissions to
	ncl-talk at ucar.edu

To subscribe or unsubscribe via the World Wide Web, visit
	http://mailman.ucar.edu/mailman/listinfo/ncl-talk
or, via email, send a message with subject or body 'help' to
	ncl-talk-request at ucar.edu

You can reach the person managing the list at
	ncl-talk-owner at ucar.edu

When replying, please edit your Subject line so it is more specific than "Re: Contents of ncl-talk digest..."


Today's Topics:

   1. UTC to local time (debasish mazumder)
   2. Re: UTC to local time (Marston Johnston)
   3. Re: Adding multiple WRF output files to a script (Mary Haley)
   4. Re: Can't turn off boundaries (Mary Haley)
   5. Help With My GFS NCl Script (Kerwyn Texeira)
   6. Re: Help With My GFS NCl Script (Dave Allured - NOAA Affiliate)
   7. Re: Can't turn off boundaries (Barry Lynn)


----------------------------------------------------------------------

Message: 1
Date: Tue, 30 Aug 2016 12:09:43 -0600
From: debasish mazumder <debasish at ucar.edu>
Subject: [ncl-talk] UTC to local time
To: "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
Message-ID: <23d24942-9f81-27e7-5427-5b3a8f990186 at ucar.edu>
Content-Type: text/plain; charset=utf-8; format=flowed

Hi

Is there any function in NCL which can shift the UTC to the local time according to the lat/lon/location?

with regards

-Deb



------------------------------

Message: 2
Date: Tue, 30 Aug 2016 20:53:08 +0200
From: Marston Johnston <shejo284 at gmail.com>
Subject: Re: [ncl-talk] UTC to local time
To: debasish mazumder <debasish at ucar.edu>
Cc: "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
Message-ID:
	<CAK68gpsC5w68qX7q-a-CpCRMY8fKqu7f4ToOjn9Rhp0YfWyFPA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi,

I'm not sure NCL has that beyond the regular time functions that converts between different expressions of time. What you are asking is rather simple, to do and a quick check of internet for UTC to local solar time, or local time according to a diffuse political map, will give you enough information to build your own function. My guess is that you are asking for local solar time.

Best,
/M

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Marston S. Johnston, PhD
Department of Earth Sciences
University of Gothenburg, Sweden
Email: marston.johnston at gu.se
Phone: +46-31-7864901
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Only the fruitful thing is true!

On Tue, Aug 30, 2016 at 8:09 PM, debasish mazumder <debasish at ucar.edu>
wrote:

> Hi
>
> Is there any function in NCL which can shift the UTC to the local time 
> according to the lat/lon/location?
>
> with regards
>
> -Deb
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160830/0761279f/attachment-0001.html 

------------------------------

Message: 3
Date: Tue, 30 Aug 2016 15:39:29 -0600
From: Mary Haley <haley at ucar.edu>
Subject: Re: [ncl-talk] Adding multiple WRF output files to a script
To: Muhammad Omer Mughal <m.mughal1 at postgrad.curtin.edu.au>
Cc: "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
Message-ID:
	<CACNN_C+tCgZd0e1-5v83kVVKfJH9uXxMjFq2-A1bCvmS2vdm1w at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

?You have to be careful when you use "addfile" and "addfiles"
interchangeably, because "addfiles" returns a list object, while "addfile"
returns a file pointer.

In your script, you are using "addfiles" to open a series of files, but then trying to use "f" as if it were a file pointer.

It's telling you where the problem is:

?    lat1  = f->XLAT(0,ny,mx)    ; the is the nearest grid point

You can't use "f->" syntax with something opened with addfiles.

One of these should work:

  lat1 = f[0]->XLAT(0,ny,mx)

or

 lat1 = wrf_user_getvar(f,"lat",0)

You will need to fix "lon1" too.

--Mary



On Tue, Aug 30, 2016 at 7:28 AM, Muhammad Omer Mughal < m.mughal1 at postgrad.curtin.edu.au> wrote:

> Hi Mary
>
>
> I tried to use addfiles for just the fourth domain as the wrf output 
> is for the fourth domain is split up into multiple files. I put all 
> the variables in a single file as it would exceed the limit of my computer.
>
>
> When I used the script you had sent earlier over just the fourth 
> domain I get the following error.
>
>
> fatal:(f) not reference to a valid file
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 22 in 
> file wrf_script-r2
>
> The script is attached again for convenience.
>
> Muhammad Omer Mughal
> MSc BSc Mechanical Engineering
> PhD  Research Scholar
> Remote Sensing and Satellite Research Group Department of Imaging and 
> Applied Physics Curtin University
>
> Curtin University
> Tel | +61 8 9266 7962
> Fax | +61 8 9266 2377
> Mobile | 0470 237 525
>
> Email | m.mughal1 at postgrad.curtin.edu.au <m.lynch at curtin.edu.au> Web | 
> http://curtin.edu.au
>
> Curtin University is a trademark of Curtin University of Technology.
> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>
>
> ------------------------------
> *From:* Mary Haley <haley at ucar.edu>
> *Sent:* Tuesday, 30 August 2016 4:21:58 AM
>
> *To:* Muhammad Omer Mughal
> *Cc:* ncl-talk at ucar.edu
> *Subject:* Re: [ncl-talk] Adding multiple WRF output files to a script
>
> It appears that you are using "addfiles" to open a bunch of WRF files 
> that are from different domains. I assume these different domain files 
> are of different spatial sizes, and hence addfiles shouldn't be used 
> to open all of them together.
>
> Addfiles is really mean to be used on similar files, for example, 
> files with the same spatial dimensions, but across different times or ensembles.
>
> It's not clear to me what you are trying to accomplish with your 
> original script, because you have a couple of calculations, but 
> nothing is really done with them.
>
> In any case, I suggest that since you are calling different types of 
> files, you will need to call "addfile" inside the loop for each file, 
> and do the necessary calculation:
>
>   FILES = systemfunc (" ls -1 " + DATADir + "wrfout* ")
>   nfiles = dimsizes(FILES)
>
>   do nf = 0,nfiles-1         ; # of files loop
>     f = addfile(FILES(nf))+".nc","r")
>     times = wrf_user_list_times(f)
>     ntimes = dimsizes(ntimes)
>
>     u = wrf_user_getvar(f,"ua",-1)      ; u averaged to mass points
>     v = wrf_user_getvar(f,"va",-1)      ; v averaged to mass points
> . . .
>
>
>
> On Mon, Aug 29, 2016 at 6:35 AM, Muhammad Omer Mughal < 
> m.mughal1 at postgrad.curtin.edu.au> wrote:
>
>> Hi Mary
>>
>>
>> Thanks for the reply. Kindly note intially ntimes was not defined due 
>> to error in the line
>>
>>
>> ntimes = dimsizes(ntimes)
>>
>> so I changed it to
>>
>> ntimes = dimsizes(times)
>>
>>
>> After that I get the error the detail of which is listed in the 
>> attached file.
>>
>>
>>
>> Muhammad Omer Mughal
>> MSc BSc Mechanical Engineering
>> PhD  Research Scholar
>> Remote Sensing and Satellite Research Group Department of Imaging and 
>> Applied Physics Curtin University
>>
>> Curtin University
>> Tel | +61 8 9266 7962
>> Fax | +61 8 9266 2377
>> Mobile | 0470 237 525
>>
>> Email | m.mughal1 at postgrad.curtin.edu.au <m.lynch at curtin.edu.au> Web 
>> | http://curtin.edu.au
>>
>> Curtin University is a trademark of Curtin University of Technology.
>> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>>
>>
>> ------------------------------
>> *From:* Mary Haley <haley at ucar.edu>
>> *Sent:* Saturday, 27 August 2016 3:22:53 AM
>> *To:* Muhammad Omer Mughal
>> *Cc:* ncl-talk at ucar.edu
>> *Subject:* Re: [ncl-talk] Adding multiple WRF output files to a 
>> script
>>
>> Dear Muhammad,
>>
>> The script you provided wouldn't run as-is, because you are 
>> referencing "times", but never setting it.
>>
>> Also, you are calling "addfiles" inside a do loop across the file 
>> names, but addfiles is meant to be used on an array of files.
>>
>> In the future, it would help if you provide the exact error message, 
>> and the full script, so we can see what line number the script is failing on.
>>
>> See the attached wrf_script_mod which is a modification of your file.
>> It's likely not going to run, but hopefully it will help you get 
>> started in using addfiles correctly.
>>
>> --Mary
>>
>>
>> On Fri, Aug 26, 2016 at 4:08 AM, Muhammad Omer Mughal < 
>> m.mughal1 at postgrad.curtin.edu.au> wrote:
>>
>>> Hi
>>>
>>>
>>> I am trying to add multiple wrfoutput files in the attached script 
>>> but I get an  error of mismatch dimensions. Can some one help please
>>>
>>>
>>>
>>>
>>>
>>> Muhammad Omer Mughal
>>> MSc BSc Mechanical Engineering
>>> PhD  Research Scholar
>>> Remote Sensing and Satellite Research Group Department of Imaging 
>>> and Applied Physics Curtin University
>>>
>>> Curtin University
>>> Tel | +61 8 9266 7962
>>> Fax | +61 8 9266 2377
>>> Mobile | 0470 237 525
>>>
>>> Email | m.mughal1 at postgrad.curtin.edu.au <m.lynch at curtin.edu.au> Web 
>>> | http://curtin.edu.au
>>>
>>> Curtin University is a trademark of Curtin University of Technology.
>>> CRICOS Provider Code 00301J (WA), 02637B (NSW)
>>>
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160830/25ae0b91/attachment-0001.html 

------------------------------

Message: 4
Date: Tue, 30 Aug 2016 15:48:18 -0600
From: Mary Haley <haley at ucar.edu>
Subject: Re: [ncl-talk] Can't turn off boundaries
To: Barry Lynn <barry.h.lynn at gmail.com>
Cc: "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
Message-ID:
	<CACNN_CL9P7CW0Xh7nvmGYEFezqWMqDDkGSqwvv5Y9Q3OyL2qKw at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Barry,

You generally don't want to set resources using get_res_value_keep, because this is an internal function.

Instead of:

      opts at mpDataBaseVersion     = get_res_value_keep(opts,
"mpDataBaseVersion","HighRes")

you should be able to set the resource directly:

      opts at mpDataBaseVersion  = "HighRes"

The reason you are not seeing the map resource take effect is because you are trying to set a map resource when creating a vector plot.

You can't set the map resources until you get to the "wrf_map_overlays"
call:

  mpres = True
  mpres at mpDataBaseVersion = "HighRes"
  .  .  . set other map resources here as desired . . .

  ov = wrf_map_overlays(a,wks,(/contour_tf,contour_psl,vector/),True,mpres)





On Tue, Aug 30, 2016 at 4:16 AM, Barry Lynn <barry.h.lynn at gmail.com> wrote:

> Hi:
>
> I have tried various options to turn off state and other boundary 
> lines but to no avail.
>
>       opts at mpDataBaseVersion     = get_res_value_keep(opts,
> "mpDataBaseVersion","HighRes")
>       opts at mpOutlineBoundarySets = get_res_value_keep(opts, 
> "mpOutlineBoundarySets", "NoBoundaries")
>       opts at mpOutlineBoundarySets = "NoBoundaries"
>       vector = wrf_vector(a,wks,u10,v10,opts)
>
> I have also tried this by itself.
>
> res at mpOutlineBoundarySets = "NoBoundaries"
>
> In the old WRF_NCL I used "HighRes" database with these settings in 
> WRFPlot.ncl (which I can't find in the new version).
>
>       opts at mpDataBaseVersion     = get_res_value_keep(opts,
> "mpDataBaseVersion","HighRes")
>        opts at mpOutlineBoundarySets = get_res_value_keep(opts, 
> "mpOutlineBoundarySets", "AllBoundaries")
> ;     opts at mpOutlineBoundarySets = get_res_value_keep(opts,
> "mpOutlineBoundarySets", "GeophysicalAndUSStates")
>
>
> Does someone have a suggestion?  I am using version 6+.
>
> Thank you,
>
> --
> Barry H. Lynn, Ph.D
> Senior Lecturer,
> The Institute of the Earth Science,
> The Hebrew University of Jerusalem,
> Givat Ram, Jerusalem 91904, Israel
> Tel: 972 547 231 170
> Fax: (972)-25662581
>
> C.E.O, Weather It Is, LTD
> Weather and Climate Focus
> http://weather-it-is.com
> Jerusalem, Israel
> Local: 02 930 9525
> Cell: 054 7 231 170
> Int-IS: x972 2 930 9525
> US 914 432 3108
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160830/a9c7fe15/attachment-0001.html 

------------------------------

Message: 5
Date: Tue, 30 Aug 2016 18:50:18 -0700
From: Kerwyn Texeira <ktish86 at gmail.com>
Subject: [ncl-talk] Help With My GFS NCl Script
To: ncl-talk at ucar.edu
Message-ID:
	<CACDQQQNquhECwCjK7jSfvb6NbC=bgqHu6tWAOoGYTG_1=pg9MA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi ncl-talk,

I getting some errors while plotting GFS analysis data.  I  believe that there is some confusion with the lat, lon and rest of the data.  The lat and lon have a 1-dimensional array while the other set of data has a 2-dimensional array.  However, I am getting a plot though but I would like to know how to correct the errors below:  I'll appreciate whatever help that I can get.

Thanks in advance!

Error message:

(0)     check_for_y_lat_coord: Warning: Data either does not contain a
valid latitude coordinate array or doesn't contain one at all.
(0)     A valid latitude coordinate array should have a 'units' attribute
equal to one of the following values:
(0)         'degrees_north' 'degrees-north' 'degree_north' 'degrees north'
'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0)     check_for_lon_coord: Warning: Data either does not contain a valid
longitude coordinate array or doesn't contain one at all.
(0)     A valid longitude coordinate array should have a 'units' attribute
equal to one of the following values:
(0)         'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'

Variable outputs:
Variable: u_wind
Type: float
Total Size: 260640 bytes
            65160 values
Number of Dimensions: 2
Dimensions and sizes:   [lat_3 | 181] x [lon_3 | 360]
Coordinates:
            lat_3: [90..-90]
            lon_3: [ 0..359]
Number Of Attributes: 13
  lv_ISBL3 :    200
  center :      US National Weather Service - NCEP (WMC)
  long_name :   u-component of wind
  units :       m/s
  _FillValue :  1e+20
  level_indicator :     100
  grid_number : 3
  parameter_table_version :     2
  parameter_number :    33
  model :       Analysis from GFS (Global Forecast System)
  forecast_time :       0
  forecast_time_units : hours
  initial_time :        01/10/2014 (18:00)

Variable: v_wind
Type: float
Total Size: 260640 bytes
            65160 values
Number of Dimensions: 2
Dimensions and sizes:   [lat_3 | 181] x [lon_3 | 360]
Coordinates:
            lat_3: [90..-90]
            lon_3: [ 0..359]
Number Of Attributes: 13
  lv_ISBL3 :    200
  center :      US National Weather Service - NCEP (WMC)
  long_name :   v-component of wind
  units :       m/s
  _FillValue :  1e+20
  level_indicator :     100
  grid_number : 3
  parameter_table_version :     2
  parameter_number :    34
  model :       Analysis from GFS (Global Forecast System)
  forecast_time :       0
  forecast_time_units : hours
  initial_time :        01/10/2014 (18:00)

Variable: hgt
Type: float
Total Size: 260640 bytes
            65160 values
Number of Dimensions: 2
Dimensions and sizes:   [lat_3 | 181] x [lon_3 | 360]
Coordinates:
            lat_3: [90..-90]
            lon_3: [ 0..359]
Number Of Attributes: 13
  lv_ISBL3 :    200
  center :      US National Weather Service - NCEP (WMC)
  long_name :   Geopotential height
  units :       gpm
  _FillValue :  1e+20
  level_indicator :     100
  grid_number : 3
  parameter_table_version :     2
  parameter_number :    7
  model :       Analysis from GFS (Global Forecast System)
  forecast_time :       0
  forecast_time_units : hours
  initial_time :        01/10/2014 (18:00)

Variable: lat1d
Type: float
Total Size: 724 bytes
            181 values
Number of Dimensions: 1
Dimensions and sizes:   [lat_3 | 181]
Coordinates:
            lat_3: [90..-90]
Number Of Attributes: 3
  long_name :   latitude
  grid_description :    65160-point (181x360) global longitude-latitude
grid.  (0,0) at 0E, 90N, matrix layout.  N.B.: prime meridian not duplicated.
  units :       degrees_north

Variable: lon1d
Type: float
Total Size: 1440 bytes
            360 values
Number of Dimensions: 1
Dimensions and sizes:   [lon_3 | 360]
Coordinates:
            lon_3: [ 0..359]
Number Of Attributes: 3
  long_name :   longitude
  grid_description :    65160-point (181x360) global longitude-latitude
grid.  (0,0) at 0E, 90N, matrix layout.  N.B.: prime meridian not duplicated.
  units :       degrees_east

Variable: temp1
Type: float
Total Size: 260640 bytes
            65160 values
Number of Dimensions: 2
Dimensions and sizes:   [181] x [360]
Coordinates:
Number Of Attributes: 1
  _FillValue :  1e+20

Variable: spd
Type: float
Total Size: 260640 bytes
            65160 values
Number of Dimensions: 2
Dimensions and sizes:   [181] x [360]
Coordinates:
Number Of Attributes: 1
  _FillValue :  1e+20

My Script:

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"

begin

a = addfile("./gfsanl_3_20140110_1800_000.grb", "r")

wks_type = "png"
wks_type at wkWidth = 2500
wks_type at wkHeight = 2500

wks= gsn_open_wks(wks_type, "speed_narr")
gsn_define_colormap(wks,"matlab_jet")

lat1d = a->lat_3
lon1d = a->lon_3
hgt = a->HGT_3_ISBL({200},:,:)
temp = a->TMP_3_ISBL({200},:,:)
u_wind = a->U_GRD_3_ISBL({200},:,:)
v_wind = a->V_GRD_3_ISBL({200},:,:)

;printVarSummary(temp)
printVarSummary(u_wind)
printVarSummary(v_wind)
printVarSummary(hgt)
printVarSummary(lat1d)
printVarSummary(lon1d)


spd = (u_wind*u_wind + v_wind*v_wind)^(0.5) ; m/s


u_wind = u_wind*1.94384449
v_wind = v_wind*1.94384449

temp1 = temp - 273
printVarSummary(temp1)
temp1!0="lat"
temp1!1="lon"

;temp1 at lat1d = lat1d
;temp1 at lon1d = lon1d

;temp1&lat at units="degrees_north"
;temp1&lon at units="degrees_east"

hgt!0="lat"
hgt!1="lon"
hgt&lat at units="degrees_north"
hgt&lon at units="degrees_east"

u_wind!0="lat"
u_wind!1="lon"
u_wind&lat at units="degrees_north"
u_wind&lon at units="degrees_east"

v_wind!0="lat"
v_wind!1="lon"
v_wind&lat at units="degrees_north"
v_wind&lon at units="degrees_east"

spd = spd*1.94384449
printVarSummary(spd)

;spd!0="lat"
;spd!1="lon"
;spd&lat at units="degrees_north"
;spd&lon at units="degrees_east"


res = True
res at gsnDraw = False
res at gsnFrame = False
res at cnLineLabelsOn =False
res at cnFillOn = True
res at mpOutlineBoundarySets = "geophysicalandusstates"
res at mpGeophysicalLineThicknessF =5.0
res at mpUSStateLineThicknessF = 5.0
res at mpNationalLineThicknessF = 5.0
res at tiMainString = "Winds (kts) at 200hpa on Jan 11 at 12:00UTC"
res at tiMainFont = "helvetica"
res at tiMainFontHeightF = 0.022
res at pmTickMarkDisplayMode = "Always"
res at mpProjection = "CylindricalEquidistant"
res at mpDataBaseVersion = "MediumRes"
res at mpOutlineOn = False
res at lbOrientation = "Vertical"
;res at tiMainOffsetYF = -0.03
res at mpFillOn  = False
res at mpOutlineOn = True
;res at tfDoNDCOverlay = True
res at mpMinLatF = 18.0
res at mpMaxLatF = 48.0
res at mpMinLonF = -160.0
res at mpMaxLonF = -114.5
res at gsnLeftString = "Geopotential Height (gpm) and Winds (kts)"
res at gsnStringFontHeightF = 0.020
res at gsnRightString = ""
res at gsnMaximize = True
res at mpShapeMode = "FreeAspect"
res at lbTitleString = "Winds (kts)"
res at lbTitleDirection = "Across"
res at lbTitleAngleF = 90
res at lbTitlePosition = "Right"
res at lbTitleFontHeightF = 0.020
res at gsnAddCyclic = False
;res at cnLevelSelectionMode = "ManualLevels"
;res at cnMinLevelValF = 10
;res at cnMaxLevelValF =130
;res at cnLevelSpacingF =10.0

res1 = True
res1 at gsnDraw = False
res1 at gsnFrame = False
res1 at cnLineColor = "Black"
res1 at gsnContourLineThicknessesScale = 7.5 res1 at gsnAddCyclic = False ;res1 at tfDoNDCOverlay = True res1 at gsnLeftString = ""
res1 at gsnRightString = ""
res1 at cnInfoLabelOn = False
res1 at cnLineLabelBackgroundColor = "white"
res1 at cnLineLabelInterval = 1.0
res1 at cnLevelSelectionMode = "EqualSpacedLevels"


res2 = True
res2 at gsnDraw = False
res2 at gsnFrame = False
res2 at vcWindBarbLineThicknessF = 3.0
res2 at vcRefLengthF =0.018
res2 at vcRefMagnitudeF = 10
;res2 at tfDoNDCOverlay = True
res2 at vcMinDistanceF = 0.025
res2 at vcGlyphStyle = "WindBarb"
res2 at gsnRightString =""
res2 at gsnLeftString = ""
res2 at vcRefAnnoOn = False
res2 at gsnAddCyclic = False


geo = gsn_csm_contour(wks, hgt, res1)

speed = gsn_csm_contour_map(wks, spd, res)

vector = gsn_csm_vector(wks, u_wind, v_wind, res2)

overlay(speed, geo)
overlay(speed, vector)

draw(speed)
frame(wks)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160830/b48aa6ad/attachment-0001.html 

------------------------------

Message: 6
Date: Tue, 30 Aug 2016 20:23:59 -0600
From: Dave Allured - NOAA Affiliate <dave.allured at noaa.gov>
Subject: Re: [ncl-talk] Help With My GFS NCl Script
To: Kerwyn Texeira <ktish86 at gmail.com>
Cc: ncl-talk at ucar.edu
Message-ID:
	<CALqwTFMerzqFd9NBJ5kHe=A1pt3yAg3kF9PWG4M6-rhDo7a5aA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Kerwyn,

(1)  In NCL, metadata is lost when using normal math operators.  You are creating the variables spd and temp1 without metadata.

There is an easy method to preserve metadata when doing math operations on arrays.  Simply assign one of the input arrays first, and then the metadata will be preserved "on the left hand side" when you use a math expression.
For example:

    spd = u_wund
    spd = (u_wind*u_wind + v_wind*v_wind)^(0.5) ; m/s

    temp1 = temp
    temp1 = temp - 273

You will now see that these new variables have proper coordinates and metadata, when you do printVarSummary AFTER these lines of code.

(2)  I think you added the following lines in an attempt to add the missing metadata.  In the case of  GFS Grib files, all of the necessary metadata should already be attached to the input variables.  Therefore you do not need to do any of the following, and they are possibly creating more problems.  I recommend removing all of these lines unless you have a good reason to keep some of them.

Do not worry about coordinate names such as lat_3 and lon_3.  That is normal with Grib files, and NCL should handle this just fine:

temp1!0="lat"
temp1!1="lon"

;temp1 at lat1d = lat1d
;temp1 at lon1d = lon1d

;temp1&lat at units="degrees_north"
;temp1&lon at units="degrees_east"

hgt!0="lat"
hgt!1="lon"
hgt&lat at units="degrees_north"
hgt&lon at units="degrees_east"

u_wind!0="lat"
u_wind!1="lon"
u_wind&lat at units="degrees_north"
u_wind&lon at units="degrees_east"

v_wind!0="lat"
v_wind!1="lon"
v_wind&lat at units="degrees_north"
v_wind&lon at units="degrees_east"

Also remove:

;spd!0="lat"
;spd!1="lon"
;spd&lat at units="degrees_north"
;spd&lon at units="degrees_east"

(3)  Here is a debugging tip.  Overlay plots are harder to debug because there is a lot going on at the same time.  Temporarily set these resources to True until you get individual plots working properly.  Then set them back to false to get only the final overlay plot:

    res at gsnDraw
    res at gsnFrame

--Dave


On Tue, Aug 30, 2016 at 7:50 PM, Kerwyn Texeira <ktish86 at gmail.com> wrote:

> Hi ncl-talk,
>
> I getting some errors while plotting GFS analysis data.  I  believe 
> that there is some confusion with the lat, lon and rest of the data.  
> The lat and lon have a 1-dimensional array while the other set of data 
> has a 2-dimensional array.  However, I am getting a plot though but I 
> would like to know how to correct the errors below:  I'll appreciate 
> whatever help that I can get.
>
> Thanks in advance!
>
> Error message:
>
> (0)     check_for_y_lat_coord: Warning: Data either does not contain a
> valid latitude coordinate array or doesn't contain one at all.
> (0)     A valid latitude coordinate array should have a 'units' attribute
> equal to one of the following values:
> (0)         'degrees_north' 'degrees-north' 'degree_north' 'degrees north'
> 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
> (0)     check_for_lon_coord: Warning: Data either does not contain a valid
> longitude coordinate array or doesn't contain one at all.
> (0)     A valid longitude coordinate array should have a 'units' attribute
> equal to one of the following values:
> (0)         'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
> 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
>
> Variable outputs:
> Variable: u_wind
> Type: float
> Total Size: 260640 bytes
>             65160 values
> Number of Dimensions: 2
> Dimensions and sizes:   [lat_3 | 181] x [lon_3 | 360]
> Coordinates:
>             lat_3: [90..-90]
>             lon_3: [ 0..359]
> Number Of Attributes: 13
>   lv_ISBL3 :    200
>   center :      US National Weather Service - NCEP (WMC)
>   long_name :   u-component of wind
>   units :       m/s
>   _FillValue :  1e+20
>   level_indicator :     100
>   grid_number : 3
>   parameter_table_version :     2
>   parameter_number :    33
>   model :       Analysis from GFS (Global Forecast System)
>   forecast_time :       0
>   forecast_time_units : hours
>   initial_time :        01/10/2014 (18:00)
>
> Variable: v_wind
> Type: float
> Total Size: 260640 bytes
>             65160 values
> Number of Dimensions: 2
> Dimensions and sizes:   [lat_3 | 181] x [lon_3 | 360]
> Coordinates:
>             lat_3: [90..-90]
>             lon_3: [ 0..359]
> Number Of Attributes: 13
>   lv_ISBL3 :    200
>   center :      US National Weather Service - NCEP (WMC)
>   long_name :   v-component of wind
>   units :       m/s
>   _FillValue :  1e+20
>   level_indicator :     100
>   grid_number : 3
>   parameter_table_version :     2
>   parameter_number :    34
>   model :       Analysis from GFS (Global Forecast System)
>   forecast_time :       0
>   forecast_time_units : hours
>   initial_time :        01/10/2014 (18:00)
>
> Variable: hgt
> Type: float
> Total Size: 260640 bytes
>             65160 values
> Number of Dimensions: 2
> Dimensions and sizes:   [lat_3 | 181] x [lon_3 | 360]
> Coordinates:
>             lat_3: [90..-90]
>             lon_3: [ 0..359]
> Number Of Attributes: 13
>   lv_ISBL3 :    200
>   center :      US National Weather Service - NCEP (WMC)
>   long_name :   Geopotential height
>   units :       gpm
>   _FillValue :  1e+20
>   level_indicator :     100
>   grid_number : 3
>   parameter_table_version :     2
>   parameter_number :    7
>   model :       Analysis from GFS (Global Forecast System)
>   forecast_time :       0
>   forecast_time_units : hours
>   initial_time :        01/10/2014 (18:00)
>
> Variable: lat1d
> Type: float
> Total Size: 724 bytes
>             181 values
> Number of Dimensions: 1
> Dimensions and sizes:   [lat_3 | 181]
> Coordinates:
>             lat_3: [90..-90]
> Number Of Attributes: 3
>   long_name :   latitude
>   grid_description :    65160-point (181x360) global longitude-latitude
> grid.  (0,0) at 0E, 90N, matrix layout.  N.B.: prime meridian not 
> duplicated.
>   units :       degrees_north
>
> Variable: lon1d
> Type: float
> Total Size: 1440 bytes
>             360 values
> Number of Dimensions: 1
> Dimensions and sizes:   [lon_3 | 360]
> Coordinates:
>             lon_3: [ 0..359]
> Number Of Attributes: 3
>   long_name :   longitude
>   grid_description :    65160-point (181x360) global longitude-latitude
> grid.  (0,0) at 0E, 90N, matrix layout.  N.B.: prime meridian not 
> duplicated.
>   units :       degrees_east
>
> Variable: temp1
> Type: float
> Total Size: 260640 bytes
>             65160 values
> Number of Dimensions: 2
> Dimensions and sizes:   [181] x [360]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  1e+20
>
> Variable: spd
> Type: float
> Total Size: 260640 bytes
>             65160 values
> Number of Dimensions: 2
> Dimensions and sizes:   [181] x [360]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :  1e+20
>
> My Script:
>
> 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"
>
> begin
>
> a = addfile("./gfsanl_3_20140110_1800_000.grb", "r")
>
> wks_type = "png"
> wks_type at wkWidth = 2500
> wks_type at wkHeight = 2500
>
> wks= gsn_open_wks(wks_type, "speed_narr")
> gsn_define_colormap(wks,"matlab_jet")
>
> lat1d = a->lat_3
> lon1d = a->lon_3
> hgt = a->HGT_3_ISBL({200},:,:)
> temp = a->TMP_3_ISBL({200},:,:)
> u_wind = a->U_GRD_3_ISBL({200},:,:)
> v_wind = a->V_GRD_3_ISBL({200},:,:)
>
> ;printVarSummary(temp)
> printVarSummary(u_wind)
> printVarSummary(v_wind)
> printVarSummary(hgt)
> printVarSummary(lat1d)
> printVarSummary(lon1d)
>
>
> spd = (u_wind*u_wind + v_wind*v_wind)^(0.5) ; m/s
>
>
> u_wind = u_wind*1.94384449
> v_wind = v_wind*1.94384449
>
> temp1 = temp - 273
> printVarSummary(temp1)
> temp1!0="lat"
> temp1!1="lon"
>
> ;temp1 at lat1d = lat1d
> ;temp1 at lon1d = lon1d
>
> ;temp1&lat at units="degrees_north"
> ;temp1&lon at units="degrees_east"
>
> hgt!0="lat"
> hgt!1="lon"
> hgt&lat at units="degrees_north"
> hgt&lon at units="degrees_east"
>
> u_wind!0="lat"
> u_wind!1="lon"
> u_wind&lat at units="degrees_north"
> u_wind&lon at units="degrees_east"
>
> v_wind!0="lat"
> v_wind!1="lon"
> v_wind&lat at units="degrees_north"
> v_wind&lon at units="degrees_east"
>
> spd = spd*1.94384449
> printVarSummary(spd)
>
> ;spd!0="lat"
> ;spd!1="lon"
> ;spd&lat at units="degrees_north"
> ;spd&lon at units="degrees_east"
>
>
> res = True
> res at gsnDraw = False
> res at gsnFrame = False
> res at cnLineLabelsOn =False
> res at cnFillOn = True
> res at mpOutlineBoundarySets = "geophysicalandusstates"
> res at mpGeophysicalLineThicknessF =5.0
> res at mpUSStateLineThicknessF = 5.0
> res at mpNationalLineThicknessF = 5.0
> res at tiMainString = "Winds (kts) at 200hpa on Jan 11 at 12:00UTC"
> res at tiMainFont = "helvetica"
> res at tiMainFontHeightF = 0.022
> res at pmTickMarkDisplayMode = "Always"
> res at mpProjection = "CylindricalEquidistant"
> res at mpDataBaseVersion = "MediumRes"
> res at mpOutlineOn = False
> res at lbOrientation = "Vertical"
> ;res at tiMainOffsetYF = -0.03
> res at mpFillOn  = False
> res at mpOutlineOn = True
> ;res at tfDoNDCOverlay = True
> res at mpMinLatF = 18.0
> res at mpMaxLatF = 48.0
> res at mpMinLonF = -160.0
> res at mpMaxLonF = -114.5
> res at gsnLeftString = "Geopotential Height (gpm) and Winds (kts)"
> res at gsnStringFontHeightF = 0.020
> res at gsnRightString = ""
> res at gsnMaximize = True
> res at mpShapeMode = "FreeAspect"
> res at lbTitleString = "Winds (kts)"
> res at lbTitleDirection = "Across"
> res at lbTitleAngleF = 90
> res at lbTitlePosition = "Right"
> res at lbTitleFontHeightF = 0.020
> res at gsnAddCyclic = False
> ;res at cnLevelSelectionMode = "ManualLevels"
> ;res at cnMinLevelValF = 10
> ;res at cnMaxLevelValF =130
> ;res at cnLevelSpacingF =10.0
>
> res1 = True
> res1 at gsnDraw = False
> res1 at gsnFrame = False
> res1 at cnLineColor = "Black"
> res1 at gsnContourLineThicknessesScale = 7.5 res1 at gsnAddCyclic = False 
> ;res1 at tfDoNDCOverlay = True res1 at gsnLeftString = ""
> res1 at gsnRightString = ""
> res1 at cnInfoLabelOn = False
> res1 at cnLineLabelBackgroundColor = "white"
> res1 at cnLineLabelInterval = 1.0
> res1 at cnLevelSelectionMode = "EqualSpacedLevels"
>
>
> res2 = True
> res2 at gsnDraw = False
> res2 at gsnFrame = False
> res2 at vcWindBarbLineThicknessF = 3.0
> res2 at vcRefLengthF =0.018
> res2 at vcRefMagnitudeF = 10
> ;res2 at tfDoNDCOverlay = True
> res2 at vcMinDistanceF = 0.025
> res2 at vcGlyphStyle = "WindBarb"
> res2 at gsnRightString =""
> res2 at gsnLeftString = ""
> res2 at vcRefAnnoOn = False
> res2 at gsnAddCyclic = False
>
>
> geo = gsn_csm_contour(wks, hgt, res1)
>
> speed = gsn_csm_contour_map(wks, spd, res)
>
> vector = gsn_csm_vector(wks, u_wind, v_wind, res2)
>
> overlay(speed, geo)
> overlay(speed, vector)
>
> draw(speed)
> frame(wks)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> end
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160830/5d156598/attachment-0001.html 

------------------------------

Message: 7
Date: Wed, 31 Aug 2016 07:28:49 +0300
From: Barry Lynn <barry.h.lynn at gmail.com>
Subject: Re: [ncl-talk] Can't turn off boundaries
To: Mary Haley <haley at ucar.edu>
Cc: "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
Message-ID:
	<CAN7Bv27run5z66ny5eqG=z6NBcL_f2=sUgLLf=2TTigb=t1WOQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi Mary:

Thank you.

However, I am left with the Meridianol line (e.g., first map plot)..

And this resource is not recognized in vector plot.

warning:gsnAddCyclic is not a valid resource in wrfwinds_vector at this time.

Barry




On Wed, Aug 31, 2016 at 12:48 AM, Mary Haley <haley at ucar.edu> wrote:

> Barry,
>
> You generally don't want to set resources using get_res_value_keep, 
> because this is an internal function.
>
> Instead of:
>
>       opts at mpDataBaseVersion     = get_res_value_keep(opts,
> "mpDataBaseVersion","HighRes")
>
> you should be able to set the resource directly:
>
>       opts at mpDataBaseVersion  = "HighRes"
>
> The reason you are not seeing the map resource take effect is because 
> you are trying to set a map resource when creating a vector plot.
>
> You can't set the map resources until you get to the "wrf_map_overlays"
> call:
>
>   mpres = True
>   mpres at mpDataBaseVersion = "HighRes"
>   .  .  . set other map resources here as desired . . .
>
>   ov = 
> wrf_map_overlays(a,wks,(/contour_tf,contour_psl,vector/),True,mpres)
>
>
>
>
>
> On Tue, Aug 30, 2016 at 4:16 AM, Barry Lynn <barry.h.lynn at gmail.com>
> wrote:
>
>> Hi:
>>
>> I have tried various options to turn off state and other boundary 
>> lines but to no avail.
>>
>>       opts at mpDataBaseVersion     = get_res_value_keep(opts,
>> "mpDataBaseVersion","HighRes")
>>       opts at mpOutlineBoundarySets = get_res_value_keep(opts, 
>> "mpOutlineBoundarySets", "NoBoundaries")
>>       opts at mpOutlineBoundarySets = "NoBoundaries"
>>       vector = wrf_vector(a,wks,u10,v10,opts)
>>
>> I have also tried this by itself.
>>
>> res at mpOutlineBoundarySets = "NoBoundaries"
>>
>> In the old WRF_NCL I used "HighRes" database with these settings in 
>> WRFPlot.ncl (which I can't find in the new version).
>>
>>       opts at mpDataBaseVersion     = get_res_value_keep(opts,
>> "mpDataBaseVersion","HighRes")
>>        opts at mpOutlineBoundarySets = get_res_value_keep(opts, 
>> "mpOutlineBoundarySets", "AllBoundaries")
>> ;     opts at mpOutlineBoundarySets = get_res_value_keep(opts,
>> "mpOutlineBoundarySets", "GeophysicalAndUSStates")
>>
>>
>> Does someone have a suggestion?  I am using version 6+.
>>
>> Thank you,
>>
>> --
>> Barry H. Lynn, Ph.D
>> Senior Lecturer,
>> The Institute of the Earth Science,
>> The Hebrew University of Jerusalem,
>> Givat Ram, Jerusalem 91904, Israel
>> Tel: 972 547 231 170
>> Fax: (972)-25662581
>>
>> C.E.O, Weather It Is, LTD
>> Weather and Climate Focus
>> http://weather-it-is.com
>> Jerusalem, Israel
>> Local: 02 930 9525
>> Cell: 054 7 231 170
>> Int-IS: x972 2 930 9525
>> US 914 432 3108
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>


--
Barry H. Lynn, Ph.D
Senior Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
US 914 432 3108
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160831/ad956f2d/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wrfwinds.pdf
Type: application/pdf
Size: 542544 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160831/ad956f2d/attachment.pdf 

------------------------------

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


End of ncl-talk Digest, Vol 153, Issue 42
*****************************************


More information about the ncl-talk mailing list