# [ncl-talk] To read ocean model output data

Dennis Shea shea at ucar.edu
Thu Nov 1 21:26:11 MDT 2018

```[0] General comment: The primary variable is:

float t(*time,* z, y, x) ;
t:long_name = "potential temperature" ;
t:units = "K" ;
t:coordinates = "east_e north_e  zz" ;

Here *time *is the *record dimension*.

function concatenates [ aggregates ] along the *record dimension [ time ]*

--

[1] The 'time' variable *is* *monotonic.*

There is nothing wrong with what you did. However, my *personal preference*
would be to

Replace:

temp  = a[:]->t
Time  = a[:]->time

With

temp   = a[:]->t
time    = temp*&*time    ; extract the 'time' associated with the
variable to be used

FYI: The *isMonotonic*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/isMonotonic.shtml>
function can test a variable

mono =* isMonotonic*(time)   ; -1 (monotonic decreasing), 0 (not
monotonic, +1 (monotonic increasing)
or
mono =* isMonotonic*(t*&*time)

Your time variable would be +1
----------------

[2] Error message:
*warning: Aggregated dimension coordinate values are non-monotonic; check
aggregated file ordering.*

The variables* east_e *and *north_e *do *NOT* have a  record dimension (
*time*)

float east_e(y, x) ;
east_e:long_name = "easting of elevation points" ;
east_e:units = "metre" ;
east_e:coordinates = "east_e north_e" ;
float north_e(y, x) ;
north_e:long_name = "northing of elevation points" ;
north_e:units = "metre" ;
north_e:coordinates = "east_e north_e" ;

Using the *[:] *syntax causes *addfiles* to use the 'y' dimension as the
record dimension. This is neither monotonic nor a record dimension.

Replace:

lon2d  = a[:]->east_e    ; <==== * [:]*
lat2d   = a[:]->north_e

I do not like using the 'lat2d' & 'lon2d' names. These are (currently) not
Latitude and Longitude.
With (say)

e2d  = a[0]->east_e    ; <====  *[0]* , Read from 1st file only. No
aggregation
n2d  = a[0]->north_e
----------------

[3] metre ==> latitude/longitude

I am not sure it can be done with the information on the file.
I have no expertise with converting 'northing'/'easting' meters to latitude
and longitude.

I *speculate* these are based upon the  *Universal Transverse Mercator* (
*UTM*)
<https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system>conformal
projection which uses a 2-dimensional Cartesian coordinate system to give
locations on the surface of the Earth.

Again, I have no expertise, but in my opinion, the additional information
needed may be a *utm_zone(y,x) *variable and a descriptor (attribute)
specifying
the base [DATUM]  being used*: *??? WGS_84_DATUM ???

Then, NCL's *utm2latlon*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/utm2latlon.shtml>
could likely be used. The interface to this function could be improved but
it can be made to work.

----
[4]

The *temp *variable uses *0* to indicate land. Really, this is a very poor
choice. Land should be set to some _FillValue. That way,
it will be ignored in any computations.

---
[5] Use *printVarSummary* and *printMinMax* to keep track of the data. It

---
[6]
That attached script plots the variable using index values. You can
recognize the Indian Ocean and aurrounding land masses.

%> ncl jyothi.ncl

Good Luck

On Thu, Nov 1, 2018 at 10:55 AM Jyothi L <jyothir033 at gmail.com> wrote:

> Thanks for the response. The output for the script is as follows:
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [ 0.. 0]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)     0
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [0.25..0.25]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    0.25
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [0.5..0.5]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    0.5
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [0.75..0.75]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    0.75
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [ 1.. 1]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)     1
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [1.25..1.25]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    1.25
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [1.5..1.5]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    1.5
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [1.75..1.75]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    1.75
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [ 2.. 2]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)     2
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [2.25..2.25]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    2.25
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [2.5..2.5]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    2.5
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [2.75..2.75]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    2.75
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [ 3.. 3]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)     3
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [3.25..3.25]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    3.25
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [3.5..3.5]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    3.5
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [3.75..3.75]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    3.75
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [ 4.. 4]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)     4
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [4.25..4.25]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    4.25
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [4.5..4.5]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    4.5
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [4.75..4.75]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)    4.75
>
>
> Variable: time (file variable)
> Type: float
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:    [time | 1]
> Coordinates:
>             time: [ 5.. 5]
> Number Of Attributes: 2
>   long_name :    time
>   units :    days since 2017-12-01 00:00:00 +00:00
> (0)     5
>
>
> On Thu, Nov 1, 2018 at 9:01 PM Mary Haley <haley at ucar.edu> wrote:
>
>> Jyothi,
>>
>> Thanks for providing the one file. We would need to see information about
>> the other files, however, in order to determine why NCL couldn't aggregate
>> the time dimension. We need to see what the time variable looks like across
>> all the files.
>>
>> It may be the case that time is monotonic on one file, but when you
>> concatenate time across several files, it may not be monotonic depending on
>> the "units" of each time variable and the values. If the units are
>> different for each file, then this is going to be an issue, because NCL
>> assumes that the aggregated dimension has the same units across all files.
>>
>> Can you run this small script for me and email the output back to
>> ncl-talk:
>>
>> dir =
>> "/incois_ncmrwfx/incois/hycom/hwrf_output/pytmp/POMcoupled_emcPHY/com/2017120100/03B/"
>> files  = systemfunc("ls " + dir + "ockhi03b.2017120100.pom.00*.nc")
>>
>> do nf=0,dimsizes(files)-1
>>   print(a->time)
>> end do
>>
>> Hopefully I don't have any typos in the code.
>>
>> Thanks,
>>
>> --Mary
>>
>>
>>
>>
>> On Wed, Oct 31, 2018 at 8:55 PM, Jyothi L <jyothir033 at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I am trying to analyze the output from a list of forecast files
>>> simulated by Ocean Model. However, I have few issues regarding this output
>>> data.
>>>
>>> 1) *Regarding Time: *
>>> I used "cat" to combine the list of 21 forecast files. My idea behind
>>> merging is to make a time vs depth section. NCl shows the following error.
>>> Should I go with join instead of cat??
>>> *ERROR*
>>> *     warning:Aggregated dimension coordinate values are non-monotonic;
>>> check aggregated file ordering.*
>>> (Is it something to do with my Time values?)
>>>
>>> printVarSummary(Time)
>>> Variable: Time
>>> Type: float
>>> Total Size: 84 bytes
>>>             21 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes:    [time | 21]
>>> Coordinates:
>>>             time: [ 0.. 5]
>>> Number Of Attributes: 2
>>>   long_name :    time
>>>   units :    days since 2017-12-01 00:00:00 +00:00
>>> (0)     0
>>> (1)    0.25
>>> (2)    0.5
>>> (3)    0.75
>>> (4)     1
>>> (5)    1.25
>>> (6)    1.5
>>> (7)    1.75
>>> (8)     2
>>> (9)    2.25
>>> (10)    2.5
>>> (11)    2.75
>>> (12)     3
>>> (13)    3.25
>>> (14)    3.5
>>> (15)    3.75
>>> (16)     4
>>> (17)    4.25
>>> (18)    4.5
>>> (19)    4.75
>>> (20)     5
>>> How do I get the regular time axis from the above values?
>>>
>>> 2) *Regarding lat and lon :*
>>> I found the units of lat and lon are in meters. I want to convert them
>>> into degrees. I could get the conversion from radians to degrees and vice
>>> versa, but not meters to degrees. And also, this data is in curvilinear
>>> grid I suppose.
>>>
>>> 2) *Regarding depth:*
>>> Model output is in sigma coordinate system, where I would like to
>>> convert it into regular depth levels(meters). I found couple of examples in
>>> this regard which didn't help me much.
>>>  ockhi03b.2017120100.pom.0000.nc
>>>
>>> ********************************
>>> Below is a sample script where I tried to plot a 2D temperature plot at
>>> first time step over surface. (to check the data)
>>>
>>> dir    =
>>> "/incois_ncmrwfx/incois/hycom/hwrf_output/pytmp/POMcoupled_emcPHY/com/2017120100/03B/"
>>> files  = systemfunc("ls " + dir + "ockhi03b.2017120100.pom.00*.nc")
>>> ListSetType(a,"cat")
>>> vNames = getfilevarnames(a[0])
>>> print(vNames)
>>>
>>> ;----- Read character variable Times
>>>
>>>  temp                = a[:]->t
>>>  Time                = a[:]->time
>>>  dep                 = a[:]->z
>>>  lon2d          = a[:]->east_e
>>>  lat2d          = a[:]->north_e
>>> ;;temp at lon2d = a[:]->east_e  ;;creating errors when I use
>>> ;;temp at lat2d  = a[:]->north_e ;;ditto
>>> printVarSummary(lon2d)
>>> printVarSummary(lat2d)
>>>
>>> wks = gsn_open_wks("png","testOceanOutput")
>>> res            = True
>>> res at cnFillOn   = True
>>> res at cnLinesOn  = False
>>>
>>> plot = gsn_csm_contour(wks,temp(0,0,:,:),res)
>>>
>>> This script makes a plot, which is INCORRECT. I have uploaded the data
>>> file using ftp. Kindly look into my data and give your suggestions.
>>>
>>>
>>> Regards
>>> Jyothi
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>> _______________________________________________
> 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/20181101/c60ec613/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jyothi.ncl
Type: application/octet-stream
Size: 2138 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181101/c60ec613/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testOceanOutput.000002.png
Type: image/png
Size: 52008 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181101/c60ec613/attachment-0001.png>
```