Re: check_for_y_lat_coord

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Thu Sep 05 2013 - 14:15:38 MDT

1) Yes, typically mpCenterLonF is the average of the mpMinLonF and
mpMaxLonF. I typically set this in my code:
res@mpCenterLonF = (res@mpMinLonF+res@mpMaxLonF)/2.

In my experience mpCenterLonF typically needs to be set when plotting a
region (=not going from 0:360E), and it almost always needs to be set
when doing a regional plot that crosses the date line at 180E.

2) This line:
u = in->Grid_0001({lon_min:lon_max},{lat_min:lat_max}) ; /100.0
results in u having no metadata transferred from Grid_0001 because you
are performing a mathematical operation on the data, and u was not
previously defined. NCL isn't sure what metadata should be transferred
from Grid_0001->u, so it does the safe thing and doesn't transfer anything.

Try this:
u = in->Grid_0001({lon_min:lon_max},{lat_min:lat_max})
u = u/100.0
or this should do the same thing:
u = in->Grid_0001({lon_min:lon_max},{lat_min:lat_max})
u = (/ u/100.0 /) ; (/ /) mean transfer data only, do not attempt
to transfer coordinate variables from right side of = sign to left side.

Adam

On 09/05/2013 01:47 PM, 朱学明 wrote:
> Thanks. I have figured out the problem. Now I still have two other
> questions :
> (1) I have setted
> vcres@mpMinLonF <mailto:vcres@mpMinLonF> = 98
> vcres@mpMaxLonF <mailto:vcres@mpMaxLonF> = 291
> Then I have a warning message as
> (0) gsn_csm_map_ce: Warning: you set mpMaxLonF to a value > 180, but
> (0) didn't set mpCenterLonF. Setting mpCenterLonF
> to 194.5
> How and when should I set mpCenterLonF? What can decide the value of
> mpCenterLonF ? Is it equal to the average of mpMinLonF and mpMaxLonF?
> (2) From the codes
> u = in->Grid_0001({lon_min:lon_max},{lat_min:lat_max})/100.0
> printVarSummary(u)
> I got the output like this,
> Variable: u
> Type: float
> Total Size: 664692 bytes
> 166173 values
> Number of Dimensions: 2
> Dimensions and sizes: [579] x [287]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 1.844674e+19
> But if I comment out the "/100.0", make the code like this
> u = in->Grid_0001({lon_min:lon_max},{lat_min:lat_max}) ; /100.0
> printVarSummary(u)
> I can get the output like this
> Variable: u
> Type: float
> Total Size: 664692 bytes
> 166173 values
> Number of Dimensions: 2
> Dimensions and sizes: [NbLongitudes | 579] x [NbLatitudes | 287]
> Coordinates:
> NbLongitudes: [98.33333333332349..290.9999999999709]
> NbLatitudes: [-17.79766126545592..60.88112837177402]
> Number Of Attributes: 5
> date : 1993-01-02 00:00:00.000000 UTC
> Date_CNES_JD : 15707
> units : cm/s
> long_name : U
> _FillValue : 1.844674e+19
> So if I want to keep /100.0 to transfer the units from centimeter to
> meter, how should I do to keep the u's attributes?
> Thanks.
> 2013-09-06
> ------------------------------------------------------------------------
> 朱学明
> ------------------------------------------------------------------------
> *发件人:*Adam Phillips <asphilli@ucar.edu>
> *发送时间:*2013-09-06 03:31
> *主题:*Re: [ncl-talk] check_for_y_lat_coord
> *收件人:*"朱学 明"<557xiaozhu@163.com>
> *抄送:*"ncl-talk@ucar.edu USERS"<ncl-talk@ucar.edu>
> If you are still getting that error message then your
> latitude/longitude coordinate variables do not have valid units
> attributes, as is stated in the error message. Please refer to the
> FAQ I previously sent. You may have to do something like this:
>
> u&NbLongitudes@units = "degrees_east"
> u&NbLatitudes@units = "degrees_north"
> v&NbLongitudes@units = "degrees_east"
> v&NbLatitudes@units = "degrees_north"
> speed&NbLongitudes@units = "degrees_east"
> speed&NbLatitudes@units = "degrees_north"
>
> If that doesn't fix the issue let ncl-tal know.
> Adam
>
> On 09/05/2013 01:21 PM, 朱学明 wrote:
>> Adam,
>> Thanks for your responding. I have added what you mentioned, but
>> the error is still there.
>> (0) 19930101
>> Variable: u
>> Type: float
>> Total Size: 664692 bytes
>> 166173 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [NbLongitudes | 579] x [NbLatitudes | 287]
>> Coordinates:
>> NbLongitudes: [98.33333333332349..290.9999999999709]
>> NbLatitudes: [-17.79766126545592..60.88112837177402]
>> Number Of Attributes: 5
>> date : 1993-01-01 00:00:00.000000 UTC
>> Date_CNES_JD : 15706
>> units : cm/s
>> long_name : U
>> _FillValue : 1.844674e+19
>> Variable: v
>> Type: float
>> Total Size: 664692 bytes
>> 166173 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [NbLongitudes | 579] x [NbLatitudes | 287]
>> Coordinates:
>> NbLongitudes: [98.33333333332349..290.9999999999709]
>> NbLatitudes: [-17.79766126545592..60.88112837177402]
>> Number Of Attributes: 5
>> _FillValue : 1.844674e+19
>> long_name : V
>> units : cm/s
>> Date_CNES_JD : 15706
>> date : 1993-01-01 00:00:00.000000 UTC
>> Variable: speed
>> Type: float
>> Total Size: 664692 bytes
>> 166173 values
>> Number of Dimensions: 2
>> Dimensions and sizes: [579] x [287]
>> Coordinates:
>> Number Of Attributes: 1
>> _FillValue : 1.844674e+19
>> (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'
>> (0) gsn_csm_map_ce: Warning: you set mpMaxLonF to a value > 180, but
>> (0) didn't set mpCenterLonF. Setting mpCenterLonF
>> to 194.5
>> The newer code is
>> do nt=nb,ne
>> time=in[:] ->time(nt-1)
>> utc_date = cd_calendar(time, -3)
>> print(""+utc_date)
>>
>> ;************************************************
>> ; read in zonal [u] and meridional [v] winds
>> ;************************************************
>> tmp = in[:]->UGRD_10maboveground(nt-1,:,:)
>> u = tmp({lat_min:lat_max},{lon_min:lon_max})/100.0
>> tmp = in[:]->VGRD_10maboveground(nt-1,:,:)
>> v = tmp({lat_min:lat_max},{lon_min:lon_max})/100.0
>> speed = sqrt(u^2 + v^2)
>> copy_VarCoords(u,speed)
>>
>> vcres@tiMainString <mailto:vcres@tiMainString> = "Wind 10m
>> above ground"
>> vcres@gsnLeftString <mailto:vcres@gsnLeftString> = utc_date
>> vcres@gsnRightString <mailto:vcres@gsnRightString> = "m/s"
>> wks = gsn_open_wks(wks_type ,"wind_"+utc_date) ;
>> open a ps file
>> gsn_define_colormap(wks,"rainbow") ;"BlAqGrYeOrRe") ;
>> choose colormap
>> printVarSummary(u)
>> printVarSummary(v)
>> printVarSummary(speed)
>> plot=gsn_csm_vector_scalar_map_ce(wks,u(NbLatitudes|:,NbLongitudes|:),v(NbLatitudes|:,NbLongitudes|:),speed(NbLatitudes|:,NbLongitudes|:),vcres)
>> ; create plot
>> end do
>> 2013-09-06
>> ------------------------------------------------------------------------
>> 朱学明
>> ------------------------------------------------------------------------
>> *发件人:*Adam Phillips <asphilli@ucar.edu>
>> *发送时间:*2013-09-06 02:56
>> *主题:*Re: [ncl-talk] check_for_y_lat_coord
>> *收件人:*"朱学 明"<557xiaozhu@163.com>
>> *抄送:*"ncl-talk@ucar.edu USERS"<ncl-talk@ucar.edu>
>> Thanks for sending printVarSummary's of your three arrays, as that
>> likely identifies the issue. Unlike your u and v arrays, your speed
>> array does not have any metadata/coordinate variables associated with
>> it.
>>
>> Try adding this after you create your speed array:
>> copy_VarCoords(u,speed)
>>
>> Alternatively, you can do this:
>> speed = u
>> speed = (/ sqrt(u^2 + v^2) /) ; overwrite speed values, but leave
>> the metadata
>>
>> This is all assuming that your NbLongitudes / NbLatitudes have units
>> attributes set. See this FAQ here:
>> http://www.ncl.ucar.edu/FAQ/#err_msgs_027
>>
>> Finally, note that your u/v/speed arrays are dimensioned longitude by
>> latitude. The gsn_csm_vector_scalar_map_ce plotting function expects
>> the order to be latitude by longitude. Thus, you will have to reorder
>> your dimensions like this:
>> plot=gsn_csm_vector_scalar_map_ce(wks,u(NbLatitudes|:,NbLongitudes|:),v(NbLatitudes|:,NbLongitudes|:),speed(NbLatitudes|:,NbLongitudes|:),vcres)
>>
>>
>> Hope that helps. If you have any further questions please respond
>> only to the ncl-talk email list.
>> Adam
>>
>> On 09/05/2013 12:39 PM, 朱学明 wrote:
>>> Hi All,
>>> I am trying to plot the geostrophic current fields from aviso.
>>> And get some screen output and error messages as follow,
>>> (0) 19930101
>>> Variable: u
>>> Type: float
>>> Total Size: 664692 bytes
>>> 166173 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes: [NbLongitudes | 579] x [NbLatitudes | 287]
>>> Coordinates:
>>> NbLongitudes: [98.33333333332349..290.9999999999709]
>>> NbLatitudes: [-17.79766126545592..60.88112837177402]
>>> Number Of Attributes: 5
>>> date : 1993-01-01 00:00:00.000000 UTC
>>> Date_CNES_JD : 15706
>>> units : cm/s
>>> long_name : U
>>> _FillValue : 1.844674e+19
>>> Variable: v
>>> Type: float
>>> Total Size: 664692 bytes
>>> 166173 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes: [NbLongitudes | 579] x [NbLatitudes | 287]
>>> Coordinates:
>>> NbLongitudes: [98.33333333332349..290.9999999999709]
>>> NbLatitudes: [-17.79766126545592..60.88112837177402]
>>> Number Of Attributes: 5
>>> _FillValue : 1.844674e+19
>>> long_name : V
>>> units : cm/s
>>> Date_CNES_JD : 15706
>>> date : 1993-01-01 00:00:00.000000 UTC
>>> Variable: speed
>>> Type: float
>>> Total Size: 664692 bytes
>>> 166173 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes: [579] x [287]
>>> Coordinates:
>>> Number Of Attributes: 1
>>> _FillValue : 1.844674e+19
>>> (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'
>>> (0) gsn_csm_map_ce: Warning: you set mpMaxLonF to a value > 180, but
>>> (0) didn't set mpCenterLonF. Setting
>>> mpCenterLonF to 194.5
>>> My code is as follow,
>>> do nt=nb,ne
>>> in = addfile(infile(nt-1),"r")
>>> utc_date = str_get_cols(infile(nt-1),44,51)
>>> print(""+utc_date)
>>>
>>> ;************************************************
>>> ; read in zonal [u] and meridional [v] winds
>>> ;************************************************
>>> tmp = in->Grid_0001
>>> u = tmp({lon_min:lon_max},{lat_min:lat_max}) ;/100.0
>>> tmp = in->Grid_0002
>>> v = tmp({lon_min:lon_max},{lat_min:lat_max}) ;/100.0
>>> speed = sqrt(u^2 + v^2)
>>>
>>> vcres@tiMainString <mailto:vcres@tiMainString>= "Geostrophic Current
>>> Field"
>>> vcres@gsnLeftString <mailto:vcres@gsnLeftString>= utc_date
>>> vcres@gsnRightString <mailto:vcres@gsnRightString> = "m/s"
>>> wks = gsn_open_wks(wks_type ,"uv_"+utc_date) ;
>>> open a ps file
>>> gsn_define_colormap(wks,"rainbow") ;"BlAqGrYeOrRe") ;
>>> choose colormap
>>> printVarSummary(u)
>>> printVarSummary(v)
>>> printVarSummary(speed)
>>> plot=gsn_csm_vector_scalar_map_ce(wks,u,v,speed,vcres) ; create plot
>>> end do
>>> Anyone can help me for figuring out the error? Thanks.
>>> 2013-09-06
>>> ------------------------------------------------------------------------
>>> 朱学明
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> --
>> ______________________________________________________________
>> Adam Phillipsasphilli@ucar.edu
>> NCAR/Climate and Global Dynamics Division (303) 497-1726
>> P.O. Box 3000
>> Boulder, CO 80307-3000http://www.cgd.ucar.edu/cas/asphilli
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> ______________________________________________________________
> Adam Phillipsasphilli@ucar.edu
> NCAR/Climate and Global Dynamics Division (303) 497-1726
> P.O. Box 3000
> Boulder, CO 80307-3000http://www.cgd.ucar.edu/cas/asphilli
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Sep 5 14:16:25 2013

This archive was generated by hypermail 2.1.8 : Mon Sep 16 2013 - 13:43:52 MDT