[ncl-talk] Non-monotonic time axis - Issue with plotting time-depth section of temperature

Jyothi Lingala jyothirao.lingala at gmail.com
Sun Oct 28 22:50:48 MDT 2018


Hi..

I am trying to plot Time vs Depth section at one location(Buoy data). I see
the time axis is not monotonic, and hence there are gaps along time axis. I
understood that NCL can't support the non-monotonic data. Following is my
script and the related errors. What could be the solution to handle this
kind of data?

***********SCRIPT********
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"

f = addfile("AD06_TS_merged.nc","r")
;print(f)

;------------Read Variables
 t = f->temp
 t_reorder = t(zax|:,time|:,latitude|:,longitude|:)
 ;printVarSummary(t_reorder)

 times = f->time(978:1011)
 ;print(times)

;-----------Convert a mixed Julian/Gregorian date to a UT-referenced date
 utc_date =  cd_calendar(times, 0)
 year     =  tointeger(utc_date(:,0))
 month    =  tointeger(utc_date(:,1))
 day      =  tointeger(utc_date(:,2))
 date_str =  sprinti("%0.4i-",year)+sprinti("%0.2i-", month) + \
            sprinti("%0.2i", day);+sprinti("%0.2i", hour)
 ;print(utc_date)
 ;print(date_str)

wks = gsn_open_wks("png","timeDepthSection_AD06")

  res                                    = True
  res at gsnAddCyclic             = False
  res at cnFillOn                     = True
  res at gsnMaximize              = True
  res at gsnYAxisIrregular2Linear =  True
  res at trYReverse               =  True

  res at vpWidthF                 = 0.65
  res at vpHeightF                = 0.3
  res at tmXTOn                   = False
  ;res at tmYLFormat             = "f" ; ; remove trailing ".0"

;---First method to label X-axis(Time axis)
  ;res at tmXBMode            = "Explicit"
  ;res at tmXBValues          = times(::4)
  ;res at tmXBLabels          = date_str(::4)

;----Second method to label X-axis(Time axis)
  restick                 = True
  restick at ttmFormat       = "%D/%c/%Y"
  time_axis_labels(times,res,restick)

plot = gsn_csm_contour(wks,t_reorder(:,:,0,0),res)

*********ERROR MESSAGE*********
warning:_NhlCreateSplineCoordApprox: Attempt to create spline approximation
for X axis failed: consider adjusting trXTensionF value
warning:IrTransInitialize: error creating spline approximation for
trXCoordPoints; defaulting to linear
warning:_NhlCreateSplineCoordApprox: Attempt to create spline approximation
for X axis failed: consider adjusting trXTensionF value
warning:IrTransInitialize: error creating spline approximation for
trXCoordPoints; defaulting to linear

*This is how my data looks like:*
Variable: f
Type: file
filename:    AD06_TS_merged
path:    AD06_TS_merged.nc

dimensions:
    latitude    = 1
    longitude    = 1
    time    = 1172 // unlimited
    zax    = 10

chunk dimensions:
    latitude    = 1
    longitude    = 1
    time    = 1
    zax    = 10

variables:
    Variable: latitude
    Type: double
    Total Size: 1 values
                8 bytes
    Number of Dimensions: 1
    Dimensions and sizes:    [ 1 <latitude> ]
    Coordinates:
                latitude: [18.48129..18.48129]
        Number of Attributes:        2
            long_name    :     latitude
            units    :     degrees_north

    Variable: longitude
    Type: double
    Total Size: 1 values
                8 bytes
    Number of Dimensions: 1
    Dimensions and sizes:    [ 1 <longitude> ]
    Coordinates:
                longitude: [67.48334..67.48334]
        Number of Attributes:        2
            long_name    :     longitude
            units    :     degrees_east

    Variable: time
    Type: double
    Total Size: 1172 values
                9376 bytes
    Number of Dimensions: 1
    Dimensions and sizes:    [ 1172 <time | unlimited> ]
    Chunking Info:    [ 512 <time> ]
    Coordinates:
                time: [42573..42732.12]
        Number of Attributes:        3
            units    :     days since 1900-12-31 00:00:00
            time_step_setting    :     auto
            time_step    :        0

    Variable: zax
    Type: double
    Total Size: 10 values
                80 bytes
    Number of Dimensions: 1
    Dimensions and sizes:    [ 10 <zax> ]
    Coordinates:
                zax: [ 1..500]
        Number of Attributes:        1
            positive    :     down

    Variable: temp
    Type: double
    Total Size: 11720 values
                93760 bytes
    Number of Dimensions: 4
    Dimensions and sizes:    [ 1172 <time | unlimited> x 10 <zax> x 1
<latitude> x 1 <longitude> ]
    Chunking Info:    [ 1 <time> x 10 <zax> x 1 <latitude> x 1 <longitude> ]
    Coordinates:
                time: [42573..42732.12]
                zax: [ 1..500]
                latitude: [18.48129..18.48129]
                longitude: [67.48334..67.48334]
        Number of Attributes:        1
            _FillValue    :     -9999

    Variable: salt
    Type: double
    Total Size: 11720 values
                93760 bytes
    Number of Dimensions: 4
    Dimensions and sizes:    [ 1172 <time | unlimited> x 10 <zax> x 1
<latitude> x 1 <longitude> ]
    Chunking Info:    [ 1 <time> x 10 <zax> x 1 <latitude> x 1 <longitude> ]
    Coordinates:
                time: [42573..42732.12]
                zax: [ 1..500]
                latitude: [18.48129..18.48129]
                longitude: [67.48334..67.48334]
        Number of Attributes:        1
            _FillValue    :     -9999

*Print time*
Variable: times
Type: double
Total Size: 272 bytes
            34 values
Number of Dimensions: 1
Dimensions and sizes:    [time | 34]
Coordinates:
            time: [42704..42708.75]
Number Of Attributes: 3
  units :    days since 1900-12-31 00:00:00
  time_step_setting :    auto
  time_step :       0
(0)    42704
(1)    42704.125
(2)    42704.25
(3)    42704.375
(4)    42704.5
(5)    42704.625
(6)    42704.75
(7)    42704.875
(8)    42705
(9)    42705.125
(10)    42705.25
(11)    42705.375
(12)    42705.625
(13)    42705.875
(14)    42706
(15)    42706.125
(16)    42706.25
(17)    42706.375
(18)    42706.5
(19)    42706.625
(20)    42707
(21)    42707.125
(22)    42707.25
(23)    42707.5
(24)    42707.625
(25)    42707.75
(26)    42707.875
(27)    42708
(28)    42708.125
(29)    42708.25
(30)    42708.375
(31)    42708.5
(32)    42708.625
(33)    42708.75


*print variableVariable: t_reorder*Type: double
Total Size: 93760 bytes
            11720 values
Number of Dimensions: 4
Dimensions and sizes:    [zax | 10] x [time | 1172] x [latitude | 1] x
[longitude | 1]
Coordinates:
            zax: [   1.. 500]
            time: [42573..42732.125]
            latitude: [18.481293..18.481293]
            longitude: [67.48333700000001..67.48333700000001]
Number Of Attributes: 1
  _FillValue :    -9999
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181029/3f2e579c/attachment.html>


More information about the ncl-talk mailing list