[ncl-talk] contour plot with 2d x,y locations ...

Ufuk Utku turuncoglu uturunco at ictp.it
Mon Nov 17 13:12:29 MST 2014


Hi Karin,

Yes, i know it has missing values. Actually, the depth is in pressure 
(dbar) and i am calculating depth using the pressure. So, for this data 
type it is normal to have different depth data for each point because 
the float travels in time and gets different measurements from different 
locations. Somehow, i need to handle this data. The plot that uses same 
dataset can be found in the following link,

http://www.euro-argo.eu/Main-Achievements/European-Contributions/Science/Regional-Seas/Med-Black-Seas/Argo-data-in-the-Black-Sea

See top panel of Fig. 2. I just want to create a similar one. Then i 
will do the same with the model results. I think that it is plotted by 
Matlab in this case but i am not sure. Thanks for your help,

Regards,

--ufuk

On 17/11/14 21:52, Karin Meier-Fleischer wrote:
> Hi Ufuk,
>
> the problem is that your calculated depth variable is a 2D variable which contains missing
> values and has varying values. If you insert print(depth) in your NCL script you will see the
> problem. For testing purpose you can define an array of 88 integers instead of using your
> depth variable:
>
>   res at sfXArray = date
>   res at sfYArray = ispan(0,87,1)
>
> By the way, it is unusual that a named dimension variable like DEPTH is not included in the
> netCDF data file? If you are able to get the correct DEPTH data it should be not a problem
> to plot it with NCL.
>
> Bye,
> Karin
>
> Am 17.11.2014 um 14:33 schrieb Ufuk Utku Turuncoglu (BE) <u.utku.turuncoglu at be.itu.edu.tr>:
>
>> Thanks. Yes you are correct. I'll attach the correct one to this mail.
>>
>> Regards,
>>
>> --ufuk
>>
>>
>> On 17/11/14 12:23, Karin Meier-Fleischer wrote:
>>> Sorry, you appended the wrong data file.
>>>
>>>
>>> Am 17.11.2014 um 10:15 schrieb Ufuk Utku Turuncoglu (BE) <u.utku.turuncoglu at be.itu.edu.tr>:
>>>
>>>> Hi,
>>>>
>>>> I am trying to create a contour plot from ocean float dataset but i could not create correct plot. To map data to x,y locations, i tried to use "TriangularMesh" resource but in this case gsn_csm_contour does not produce anything (just empty plot with weird axis). If i remove "TriangularMesh" definition, then NCL creates the plot but it does not create the axises and gives following warnings.
>>>>
>>>> warning:PlotManagerSetValues: TickMark annotation cannot be added after NhlCreate
>>>> warning:tmXBLabelFontHeightF is not a valid resource in plot_glpr_2d_contour.PlotManager at this time
>>>> warning:tmYLLabelFontHeightF is not a valid resource in plot_glpr_2d_contour.PlotManager at this time
>>>>
>>>> So, what is the correct way to create this kind of float plots.
>>>>
>>>> PS: i also attached the data file to mail.
>>>>
>>>> Thanks,
>>>> Regards,
>>>>
>>>> --ufuk
>>>>
>>>> ;-----------------------------------------------------------
>>>> 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
>>>>   ;--- parameters ---
>>>>   ifile = "GL_PR_PF_1901200.nc"
>>>>
>>>>   ;--- open file ---
>>>>   nc1 = addfile(ifile, "r")
>>>>
>>>>   ;--- read variables ---
>>>>   time = nc1->TIME
>>>>   pres = nc1->PRES
>>>>   date = cd_calendar(time, 4)
>>>>   plat = nc1->LATITUDE
>>>>   plon = nc1->LONGITUDE
>>>>   data = nc1->TEMP
>>>>
>>>>   dims = dimsizes(pres)
>>>>   ntime = plat(0)
>>>>   nlev = plat(1)
>>>>
>>>>   ;--- calculate depth from pressure ---
>>>>   ;--- UNESCO Technical Papers in Marine Science No. 44 ---
>>>>   ;--- http://www.seabird.com/document/an69-conversion-pressure-depth ---
>>>>   x = (sin(plat/57.29578))^2
>>>>   x2d = conform(pres, x, (/ 0 /))
>>>>   g = 9.780318*(1.0+(5.2788e-3+2.36e-5*x2d)*x2d)+1.092e-6*pres
>>>>   depth = pres
>>>>   depth = ((((-1.82e-15*pres+2.279e-10)*pres-2.2512e-5)*pres+9.72659)*pres)/g
>>>>
>>>>   ;--- plot data ---
>>>>   wks  = gsn_open_wks ("newpdf", "plot_glpr_2d")
>>>>   gsn_define_colormap (wks, "matlab_jet")
>>>>   i = NhlNewColor(wks,0.8,0.8,0.8)
>>>>
>>>>   res = True
>>>>   res at vpHeightF = 0.15
>>>>   res at vpWidthF = 0.75
>>>>   res at tiYAxisString = "Depth (m)"
>>>>   res at tiXAxisString = "Time"
>>>>   res at gsnLeftString = ""
>>>>   res at gsnRightString = ""
>>>>   res at gsnSpreadColors = True
>>>>   res at gsnSpreadColorEnd = -3
>>>>   res at cnFillOn = True
>>>>   res at cnFillMode = "RasterFill"
>>>>   res at cnInfoLabelOn = False
>>>>   res at cnLinesOn = False
>>>>   res at cnLineLabelsOn = False
>>>>   res at lbLabelBarOn = False
>>>>   res at pmTickMarkDisplayMode = "Always"
>>>>   res at tiXAxisFontHeightF = 0.008
>>>>   res at tiYAxisFontHeightF = 0.008
>>>>   res at tmXBLabelFontHeightF = 0.008
>>>>   res at tmYLLabelFontHeightF = 0.008
>>>>
>>>>   xa = conform(pres, date, (/ 0 /))
>>>>   copy_VarCoords(pres, xa)
>>>>   xa = mask(xa, ismissing(depth), False)
>>>>   res at sfXArray = xa(DEPTH|:,TIME|:)
>>>>   res at sfYArray = depth(DEPTH|:,TIME|:)
>>>>   res at trGridType = "TriangularMesh"
>>>>   res at trYReverse = True
>>>>
>>>>   plot1 = gsn_csm_contour(wks, data(DEPTH|:,TIME|:), res)
>>>> end
>>>> <GL_TS_PF_1901200.nc>_______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> ____________________________________
>>> Dipl. Geophys. Karin Meier-Fleischer
>>> Visualisierung
>>> Abteilung Anwendungen
>>>
>>> Deutsches Klimarechenzentrum GmbH (DKRZ)
>>> Bundesstrasse 45a * D-20146 Hamburg
>>> Germany
>>>
>>> Phone:	+49 (0)40 460094 126
>>> Fax:	+49 (0)40 460094 270
>>> E-Mail:	meier-fleischer at dkrz.de
>>> URL:	http://www.dkrz.de/
>>>
>>> Geschäftsführer: Prof. Dr. Thomas Ludwig
>>> Sitz der Gesellschaft: Hamburg
>>> Amtsgericht Hamburg HRB 39784
>>>
>>>
>>>
>>>
>> <GL_PR_PF_1901200.nc>
> ____________________________________
> Dipl. Geophys. Karin Meier-Fleischer
> Visualisierung
> Abteilung Anwendungen
>
> Deutsches Klimarechenzentrum GmbH (DKRZ)
> Bundesstrasse 45a * D-20146 Hamburg
> Germany
>
> Phone:	+49 (0)40 460094 126
> Fax:	+49 (0)40 460094 270
> E-Mail:	meier-fleischer at dkrz.de
> URL:	http://www.dkrz.de/
>
> Geschäftsführer: Prof. Dr. Thomas Ludwig
> Sitz der Gesellschaft: Hamburg
> Amtsgericht Hamburg HRB 39784
>
>
>
>



More information about the ncl-talk mailing list