Re: [ coordinates : lat lon (0) check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all...

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed May 14 2014 - 09:29:49 MDT

Thanks for providing the scripts offline.

I don't quite understand the metadata on this file, because your main "tos" variable *does* have 1D coordinate arrays attached to it, but when I try to plot the data using these arrays, the data are shifted with regard to the map outlines. So, I don't think you want to use these!

The main problem is that it looks like the value 0.0 is being used as a missing value, which is generally not a good idea. So, right after reading "t" off the file, you need to add a "where" statement to replace all those 0.0 values with the missing value:

;---Set all 0.0 vaues to missing
t = where(t.eq.0,t@_FillValue,t)

Then, instead of this call, which is copying over the "bad" 1D coordinate arrays:

copy_VarCoords(t, tsm)

do this:

copy_VarAtts(t, tsm)

I believe you are already doing this, but make sure you attach lat2d and lon2d:

tsm@lat2d = f[0]->lat
tsm@lon2d = f[0]->lon

Finally, to fix that white strip that you see, you need to turn on the cyclic point resource:

res@gsnAddCyclic = True ; Add a cyclic point in longitude

See the attached plot. I'll send you the modified scrip offline.

--Mary

On May 13, 2014, at 3:57 PM, Mary Haley <haley@ucar.edu> wrote:

> Can you provide your dataset and your most current script?
>
> I think this may be a gsnAddCyclic issue, but it looks like there are other things going on too, like Gus suggested, with the displaced poles.
>
> --Mary
>
> On May 13, 2014, at 1:51 PM, Vanúcia Schumacher <vanucia-schumacher@hotmail.com> wrote:
>
>> It worked, but not this plotting correctly on the map, the graph is strange
>>
>>
>>
>>
>> ---
>> Vanúcia Schumacher
>> Mestranda em Meteorologia - UFV
>> Meteorologista -UFPel
>> Departamento de Meteorologia Agrícola - DEA
>> Cel: (31) 9978 2522
>> DEA: (31) 3899 1890
>>
>>
>>> Subject: Re: [ coordinates : lat lon (0) check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all...
>>> From: haley@ucar.edu
>>> Date: Tue, 13 May 2014 13:42:12 -0600
>>> CC: ncl-talk@ucar.edu
>>> To: vanucia-schumacher@hotmail.com
>>>
>>> Sorry, I had a typo. I had you do this:
>>>
>>>> media@lat2d=f[:]->lat
>>>> media@lon2d=f[:]->lon
>>>
>>> when it should be:
>>>
>>>> media@lat2d=f[0]->lat
>>>> media@lon2d=f[0]->lon
>>>
>>>
>>> Note, and this is important: this assumes that your lat/lon values are the same across all data files. Is this the case?
>>>
>>> --Mary
>>>
>>> On May 13, 2014, at 1:26 PM, Vanúcia Schumacher <vanucia-schumacher@hotmail.com> wrote:
>>>
>>>> Hi Mary,
>>>>
>>>> I did what you suggested, but now new error appeared:
>>>>
>>>> fatal:Eq: Dimension size, for dimension number 0, of operands does not match, can't continue
>>>>
>>>> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 887 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>>>
>>>> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 1508 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>>>
>>>> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 6845 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>>>
>>>> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 57 in file tsm.ncl
>>>>
>>>> Look data print:
>>>>
>>>> dimensions:
>>>> time = 360 // unlimited
>>>> j = 149
>>>> i = 182
>>>> bnds = 2
>>>> vertices = 4
>>>> variables:
>>>> double time ( time )
>>>> bounds : time_bnds
>>>> units : days since 1981-01-01 00:00:00
>>>> calendar : noleap
>>>> axis : T
>>>> long_name : time
>>>> standard_name : time
>>>>
>>>> double time_bnds ( time, bnds )
>>>>
>>>> integer j ( j )
>>>> units : 1
>>>> long_name : cell index along second dimension
>>>>
>>>> integer i ( i )
>>>> units : 1
>>>> long_name : cell index along first dimension
>>>>
>>>> float lat ( j, i )
>>>> standard_name : latitude
>>>> long_name : latitude coordinate
>>>> units : degrees_north
>>>> bounds : lat_vertices
>>>>
>>>> float lon ( j, i )
>>>> standard_name : longitude
>>>> long_name : longitude coordinate
>>>> units : degrees_east
>>>> bounds : lon_vertices
>>>>
>>>> float lat_vertices ( j, i, vertices )
>>>> units : degrees_north
>>>>
>>>> float lon_vertices ( j, i, vertices )
>>>> units : degrees_east
>>>>
>>>> float tos ( time, j, i )
>>>> standard_name : sea_surface_temperature
>>>> long_name : Sea Surface Temperature
>>>>
>>>>
>>>> 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
>>>>
>>>> fils = systemfunc("ls *.nc")
>>>> f = addfiles(fils, "r")
>>>> ListSetType(f,"join")
>>>> t =f[:]->tos(:,0,:,:)
>>>> tsm = t - 273.15
>>>> copy_VarCoords(t, tsm)
>>>> media= dim_avg_n_Wrap(tsm, 0)
>>>>
>>>> media@lat2d=f[:]->lat
>>>> media@lon2d=f[:]->lon
>>>>
>>>> wkstype= "png"
>>>> wkstype@wkWidth = 1000
>>>> wkstype@wkHeight = 1000
>>>> wks = gsn_open_wks(wkstype,"tsm")
>>>> gsn_define_colormap(wks,"BlAqGrYeOrRe")
>>>> res = True
>>>> ;res@mpMinLonF = 0
>>>> ;res@mpMaxLonF = 360
>>>> ;res@mpCenterLonF = 180
>>>> res@tiMainString = "TSM"
>>>> res@gsnLeftString = "CCCma-CanCM4"
>>>> res@cnLinesOn = False
>>>> res@cnFillOn = True
>>>> plot = gsn_csm_contour_map_ce(wks,media,res)
>>>> end
>>>>
>>>>
>>>>
>>>>
>>>> ---
>>>> Vanúcia Schumacher
>>>> Mestranda em Meteorologia - UFV
>>>> Meteorologista -UFPel
>>>> Departamento de Meteorologia Agrícola - DEA
>>>> Cel: (31) 9978 2522
>>>> DEA: (31) 3899 1890
>>>>
>>>>
>>>>> Subject: Re: ERROR[ coordinates : lat lon (0) check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all...
>>>>> From: haley@ucar.edu
>>>>> Date: Tue, 13 May 2014 09:47:28 -0600
>>>>> CC: ncl-talk@ucar.edu
>>>>> To: vanucia-schumacher@hotmail.com
>>>>>
>>>>> Vanúcia,
>>>>>
>>>>> It looks to me like you have a curvilinear grid and not a rectilinear grid, so you are going to be unable to use coordinate arrays, which is what you were trying to do with this code:
>>>>>
>>>>>>> lat = f[:]->i
>>>>>>> lon = f[:]->j
>>>>>>> t&i = lat
>>>>>>> t&j = lon
>>>>>
>>>>> The "printVarSummary" of "t" indicates that your "t" variable has coordinates called "lat" and "lon", and hopefully these are on the file, and are two-dimensional. If so, try this (UNTESTED):
>>>>>
>>>>> 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
>>>>> fils = systemfunc("ls *.nc")
>>>>> f = addfiles(fils, "r")
>>>>> ListSetType(f,"join")
>>>>> t =f[:]->tos(:,0,:,:
>>>>>
>>>>> tsm = t - 273.15
>>>>> media= dim_avg_n_Wrap(tsm, 0)
>>>>> media@lat2d = lat = f[:]->lat
>>>>> media@lon2d = f[:]->lon
>>>>> res = True
>>>>> plot = gsn_csm_contour_map_ce(wks,media,res)
>>>>> end
>>>>>
>>>>>
>>>>> Note that I'm not setting any plot options via "res" here, so you are going to get a very bare-bones plot.
>>>>>
>>>>> For a sample of some plot options you might want to set, see the templates at:
>>>>>
>>>>> http://www.ncl.ucar.edu/Applications/Templates/#PlotsOverMapsTemplates
>>>>>
>>>>> In particular, look at "contour_map_template.ncl".
>>>>>
>>>>> --Mary
>>>>>
>>>>> On May 12, 2014, at 1:35 PM, Vanúcia Schumacher <vanucia-schumacher@hotmail.com> wrote:
>>>>>
>>>>>> Hi users,
>>>>>>
>>>>>> I'll trying to plot global map, but lat and lon have different names in variable:
>>>>>>
>>>>>>> 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
>>>>>>> fils = systemfunc("ls *.nc")
>>>>>>> f = addfiles(fils, "r")
>>>>>>> ListSetType(f,"join")
>>>>>>
>>>>>>> t =f[:]->tos(:,0,:,:)
>>>>>>
>>>>>>> lat = f[:]->i
>>>>>>> lon = f[:]->j
>>>>>>> t&i = lat
>>>>>>> t&j = lon
>>>>>>> tsm = t - 273.15
>>>>>>> media= dim_avg_n_Wrap(tsm, 0)
>>>>>>> plot = gsn_csm_contour_map_ce(wks,media,res)
>>>>>>> end
>>>>>>
>>>>>>> printVarSummary(t)
>>>>>>
>>>>>>
>>>>>> Variable: t
>>>>>> Type: float
>>>>>> Total Size: 108472 bytes
>>>>>> 27118 values
>>>>>> Number of Dimensions: 3
>>>>>> Dimensions and sizes: [ncl_join | 1] x [j | 149] x [i | 182]
>>>>>> Coordinates:
>>>>>> j: [1..149]
>>>>>> i: [1..182]
>>>>>> Number Of Attributes: 14
>>>>>> time : 15.5
>>>>>> standard_name : sea_surface_temperature
>>>>>> long_name : Sea Surface Temperature
>>>>>> comment : "this may differ from ""surface temperature"" in regions of sea ice."
>>>>>> units : K
>>>>>> original_name : sosstsst
>>>>>> original_units : degC
>>>>>> history : 2011-11-09T14:11:22Z altered by CMOR: Converted units from 'degC' to 'K'. 2011-11-09T14:11:22Z altered by CMOR: replaced missing value flag (9.96921e+36) with standard missing value (1e+20).
>>>>>> cell_methods : time: mean (interval: 30 minutes)
>>>>>> cell_measures : area: areacello
>>>>>> missing_value : 1e+20
>>>>>> _FillValue : 1e+20
>>>>>> associated_files : baseURL: http://cmip-pcmdi.llnl.gov/CMIP5/dataLocation gridspecFile: gridspec_ocean_fx_IPSL-CM5A-LR_decadal1980_r0i0p0.nc areacello: areacello_fx_IPSL-CM5A-LR_decadal1980_r0i0p0.nc
>>>>>> coordinates : lat lon
>>>>>> (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'
>>>>>>
>>>>>> Help me!
>>>>>>
>>>>>> ---
>>>>>> Vanúcia Schumacher
>>>>>> Mestranda em Meteorologia - UFV
>>>>>> Meteorologista -UFPel
>>>>>> Departamento de Meteorologia Agrícola - DEA
>>>>>> Cel: (31) 9978 2522
>>>>>> DEA: (31) 3899 1890
>>>>>> _______________________________________________
>>>>>> ncl-talk mailing list
>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>> <tsm.png>_______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed May 14 09:30:05 2014

This archive was generated by hypermail 2.1.8 : Tue May 20 2014 - 10:18:04 MDT