vector/array writing

From: Ioana Colfescu <colfescu_at_nyahnyahspammersnyahnyah>
Date: Wed Apr 28 2010 - 07:42:57 MDT

Hi,

I have a very simple question: I want to write an array with years (1970 1971 .... 1999) and var0 = (/{1970:1:1999}/) doesn't work though {| : } works in selecting special parts of a dimension in a variable.Could someone tell me how should I write this correctly? Sorry the question is very simple but I didn't find in the documentation yet anything.

----- Original Message -----
From: ncl-talk-request@ucar.edu
To: ncl-talk@ucar.edu
Sent: Tuesday, April 27, 2010 10:34:26 PM
Subject: ncl-talk Digest, Vol 77, Issue 77

Send ncl-talk mailing list submissions to
ncl-talk@ucar.edu

To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.ucar.edu/mailman/listinfo/ncl-talk or, via email, send a
message with subject or body 'help' to
ncl-talk-request@ucar.edu

You can reach the person managing the list at
ncl-talk-owner@ucar.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of ncl-talk digest..."

Today's Topics:

1. usage of get1Dindex function ... (u.utku.turuncoglu@be.itu.edu.tr)
2. Re: usage of get1Dindex function ... (Dennis Shea)
3. Conservative remapping - grid cell corners (Ashley Watson)
4. sorting out the files (p s)
5. Re: sorting out the files (David Brown)
6. Re: sorting out the files (Jonathan Vigh)
7. Re: missing_value problem about GODAS monthly data (moon)

----------------------------------------------------------------------

Message: 1
Date: Tue, 27 Apr 2010 21:22:33 +0300 (EEST)
From: u.utku.turuncoglu@be.itu.edu.tr
Subject: usage of get1Dindex function ...
To: ncl-talk@ucar.edu
Message-ID:
<50178.160.75.177.22.1272392553.squirrel@webmail.be.itu.edu.tr>
Content-Type: text/plain;charset=iso-8859-1

Hi,

I wrote the following procedure to sort x,y coordinate pair based on
selected one. The opt controls the behavior of the sort procedure. If
the value is equal to 1 then, it sorts the x values and match the
correct y
with it.

undef("sort_xy")
procedure sort_xy(x:numeric, y:numeric, opt:numeric)
local x_old, y_old, x_ind, y_ind
begin ;--- sort x ---
if (opt .eq. 1) then
x_old = x
qsort(x) x_ind = get1Dindex(x_old, x)
y_old = y
y = y(x_ind)
;--- sort y ---
else y_old = y
qsort(y) y_ind = get1Dindex(y_old, y)
x_old = x
x = x(y_ind)
end if
end

when i run this procedure,

xxx = (/ 3, 5, 2, 10, 6, 4, 3 /)
yyy = (/ 1, 8, 4, 3 , 7, 6, 2 /)
sort_xy(xxx, yyy, 1)

it gives the "fatal:Dimension sizes on right hand side of assignment do
not match dimension sizes of left hand side" error in the "get1Dindex"
call line. The dimension of the arrays y_old and y or x_old and x is
same and the second argument is sorted. I could not find the source of
problem. Is there any special requirement to use "get1Dindex" function?
How can i
solve it?

Thanks,

--ufuk

-- This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

------------------------------

Message: 2
Date: Tue, 27 Apr 2010 13:02:07 -0600
From: Dennis Shea <shea@ucar.edu>
Subject: Re: usage of get1Dindex function ...
To: u.utku.turuncoglu@be.itu.edu.tr
Cc: ncl-talk@ucar.edu
Message-ID: <4BD734AF.9010403@ucar.edu>
Content-Type: text/plain; charset="iso-8859-1"

Hi Ufuk

Actually the "get1Dindex" fuction notes the following:

"The input arguments should contain only unique values. Duplicate
entries will lead to a fatal error."

I ahve attached a script that contains an example.
It also (I think) illustrates an error in your
original script. The fact that subscripts are repeated means that
the reurn size might be different ... thay are!!!.

Good luck

On 04/27/2010 12:22 PM, u.utku.turuncoglu@be.itu.edu.tr wrote:
> Hi,
>
> I wrote the following procedure to sort x,y coordinate pair based on
> selected one. The opt controls the behavior of the sort procedure. If
> the value is equal to 1 then, it sorts the x values and match the
> correct y
> with it.
>
> undef("sort_xy")
> procedure sort_xy(x:numeric, y:numeric, opt:numeric)
> local x_old, y_old, x_ind, y_ind
> begin
> ;--- sort x ---
> if (opt .eq. 1) then
> x_old = x
> qsort(x) x_ind = get1Dindex(x_old, x)
> y_old = y
> y = y(x_ind)
> ;--- sort y ---
> else
> y_old = y
> qsort(y) y_ind = get1Dindex(y_old, y)
> x_old = x
> x = x(y_ind)
> end if
> end
>
> when i run this procedure,
>
> xxx = (/ 3, 5, 2, 10, 6, 4, 3 /)
> yyy = (/ 1, 8, 4, 3 , 7, 6, 2 /)
> sort_xy(xxx, yyy, 1)
>
> it gives the "fatal:Dimension sizes on right hand side of assignment
> do not match dimension sizes of left hand side" error in the
> "get1Dindex" call line. The dimension of the arrays y_old and y or
> x_old and x is same
> and the second argument is sorted. I could not find the source of
> problem. Is there any special requirement to use "get1Dindex"
> function? How can i
> solve it?
>
> Thanks,
>
> --ufuk
>
>

-- ======================================================
Dennis J. Shea tel: 303-497-1361 |
P.O. Box 3000 fax: 303-497-1333 |
Climate Analysis Section |
Climate & Global Dynamics Div. |
National Center for Atmospheric Research |
Boulder, CO 80307 |
USA email: shea 'at' ucar.edu |
======================================================
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tst_get1Dindex_multiple.ncl
Url:
http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20100427/3488c4ef/attachment.pl

------------------------------

Message: 3
Date: Tue, 27 Apr 2010 22:11:11 +0200
From: Ashley Watson <ashleywats@gmail.com>
Subject: Conservative remapping - grid cell corners
To: ncl-talk@ucar.edu
Message-ID:
<n2gf83b83e41004271311hf7e21d7cx58ce312f2864dad7@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Dear All,

I want interpolate model output to regular grid using conservative
remapping. As NCL function "area_conserve_remap" works only for regular
grids, I have to use either SCRIP or CDO. I tried cdo but I found it
requires corner points of grid cells. In my input file, I have only
lat2d and lon2d ( grid cell centers). Does someone have ncl script to
calculate grid cell corners and invoke cdo *remapcon* to do conservative
remapping. Or
any hint or function to calculate get corners from grid cell centers?

Thanks in advance
Regards Ashley
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20100427/87ebd2ca/attachment.html

------------------------------

Message: 4
Date: Tue, 27 Apr 2010 17:26:30 -0400
From: p s <prabshr@gmail.com>
Subject: sorting out the files
To: ncl-talk@ucar.edu
Message-ID:
<s2x8c65c1ab1004271426j7521e99fi92fdcd08295cba90@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi,
I am trying to read multipled 3B42 hdf 3hourly files and write it out as
a single netcdf file. The problem I am coming across is due to the way
the HDF
filenames are:

3B42.090609.0.6A.HDF
3B42.090609.12.6A.HDF 3B42.090609.15.6A.HDF
3B42.090609.18.6A.HDF 3B42.090609.21.6A.HDF
3B42.090609.3.6A.HDF 3B42.090609.6.6A.HDF

When I use systemfunc to list the files and read in, they do not appear
in sequential time order, like 0, 3, 6, 15, 18, 21 because of the size
of hr
array in filename
so the data is stored in netcdf in different time order (0, 12, 15, 18,
21, 3, 6), which I want to correct.

Could you please kindly help me to sort out this issue.

Regards,
Prabhakar
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20100427/62392ddb/attachment.html

------------------------------

Message: 5
Date: Tue, 27 Apr 2010 16:06:54 -0600
From: David Brown <dbrown@ucar.edu>
Subject: Re: sorting out the files
To: p s <prabshr@gmail.com>
Cc: ncl-talk@ucar.edu
Message-ID: <6ECFA61B-7A47-4758-AAE2-42864F25B23D@ucar.edu>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

Hi Prabhakar,

One solution would be to create a file with just the names of the HDF
files arranged in the order you want:

3B42.090609.0.6A.HDF
3B42.090609.3.6A.HDF 3B42.090609.6.6A.HDF
3B42.090609.12.6A.HDF 3B42.090609.15.6A.HDF
3B42.090609.18.6A.HDF 3B42.090609.21.6A.HDF

You could use
ls -1 *.HDF > input_hdf_files

to get the initial list, and then rearrange it manually into the
correct order. Then instead of doing "ls" as the systemfunc command,
you could say:

infiles = systemfunc("cat input_hdf_files")

Hope this helps,
-dave

On Apr 27, 2010, at 3:26 PM, p s wrote:

> Hi,
> I am trying to read multipled 3B42 hdf 3hourly files and write it
> out as a single netcdf file. The problem I am coming across is due
> to the way the HDF filenames are:
>
>
> 3B42.090609.0.6A.HDF
> 3B42.090609.12.6A.HDF 3B42.090609.15.6A.HDF
> 3B42.090609.18.6A.HDF 3B42.090609.21.6A.HDF
> 3B42.090609.3.6A.HDF 3B42.090609.6.6A.HDF
>
>
>
> When I use systemfunc to list the files and read in, they do not
> appear in sequential time order, like 0, 3, 6, 15, 18, 21 because of
> the size of hr array in filename
> so the data is stored in netcdf in different time order (0, 12, 15,
> 18, 21, 3, 6), which I want to correct.
>
> Could you please kindly help me to sort out this issue.
>
> Regards,
> Prabhakar
> _______________________________________________ ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

------------------------------

Message: 6
Date: Tue, 27 Apr 2010 16:36:00 -0600
From: Jonathan Vigh <jvigh@ucar.edu>
Subject: Re: sorting out the files
To: p s <prabshr@gmail.com>
Cc: ncl-talk@ucar.edu
Message-ID: <4BD766D0.70704@ucar.edu>
Content-Type: text/plain; charset="iso-8859-1"

Hi Prabhakar,
If you have a small number of files, then David Brown's solution is
the easiest But if you have many files, or you are not able to
physically rename them (for example, if they are on a remote server or
you don't have write permission), then you have to be clever.

What you can do is to read it the filenames, parse them into their
separate parts, rewrite the file names in a way that can be sorted by
NCL's string sort function (sqsort). If you first attach the original
filenames as an attribute array to the list of new filenames, then you
sort on the rehashed filenames and the attached attribute array of old
names will be sorted into the correct order. You can then use that list
of the old names sorted in the correct order.

This might sounds hard, but it's really not too bad. I've attached a
script that will do this for you.

Best regards,
Jonathan

p s wrote:
> Hi, I am trying to read multipled 3B42 hdf 3hourly files and write it
> out as a single netcdf file. The problem I am coming across is due to
> the
> way the HDF filenames are:
>
>
> 3B42.090609.0.6A.HDF
> 3B42.090609.12.6A.HDF 3B42.090609.15.6A.HDF
> 3B42.090609.18.6A.HDF 3B42.090609.21.6A.HDF
> 3B42.090609.3.6A.HDF 3B42.090609.6.6A.HDF
>
>
>
> When I use systemfunc to list the files and read in, they do not
> appear in sequential time order, like 0, 3, 6, 15, 18, 21 because of
> the size of hr array in filename
> so the data is stored in netcdf in different time order (0, 12, 15,
> 18, 21, 3, 6), which I want to correct.
>
> Could you please kindly help me to sort out this issue.
>
> Regards,
> Prabhakar
> ------------------------------------------------------------------------
>
> _______________________________________________ ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rename.ncl
Url:
http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20100427/870f3335/attachment.pl

------------------------------

Message: 7
Date: Wed, 28 Apr 2010 10:34:19 +0800
From: moon <nightmoon35@gmail.com>
Subject: Re: missing_value problem about GODAS monthly data
To: ncl-talk@ucar.edu
Message-ID: <op.vbupfhb8gbhnh9@guanyue>
Content-Type: text/plain; charset="gbk"

Dear Dennis,

Thanks, _fillvalue worked. But there is anonther problem about panel
common bar.
Still using this ncl script, I want to draw a panel figure using a
common bar. So I add the command

res@lbLabelBarOn = False ; turn off individual cb

and creat the panel,but the common label bar didn't appear. Is there
any problem?
__________________________________________________________________________________________
do nt=0,3
plot(nt%2,nt/2)=gsn_csm_vector_scalar_map_ce(wks,u(nt,{minLat:maxLat},{minLon:maxLon})
\ ,v(nt,{minLat:maxLat},{minLon:maxLon})
\ ,dzdt(nt,{minLat:maxLat},{minLon:maxLon})
, res)
end do
;************************************************ ; create panel
;************************************************ resP = True ; modify
the panel plot
; resP@gsnFrame = False ; don't advance panel
plot resP@gsnPanelLabelBar = True ; add common colorbar
resP@lbLabelStride = 2 ; automatically choose
best stride
resP@gsnSpreadColors = True ; use full range of color
map resP@gsnMaximize = True ; fill up the page
plotone=ndtooned(plot) gsn_panel(wks,plotone,(/2,2/),resP) ; now draw as
one plot
___________________________________________________________________________________

Thanks

moon

? Wed, 28 Apr 2010 00:27:38 +0800?Dennis Shea <shea@ucar.edu> ??:

> I see the issue. This is a good example of the "golden rule of
> data processing" .... Look at your data before processing.
>
> Consider:
>
> b = addfile(diri + f2, "r")
> us = b->ucur(:,{5},:,:) ; us is type short
> printVarSummary(us)
>
> Variable: us
> Type: short <=============================
> Total Size: 3611520 bytes
> 1805760 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 12] x [lat | 418] x [lon | 360]
> Coordinates:
> time: [35429..35763]
> lat: [-74..64.999]
> lon: [ 1..360]
> Number Of Attributes: 20
> level : 5
> missing_value : 32767 <=============================
> [snip]
> _FillValue : 32766 <=============================
> [snip]
> add_offset : 0
> scale_factor : 0.000122074
> valid_range : ( -2, 2 )
> actual_range : ( -1.51604, 1.53069 )
>
> --- Note the the missing_value and _FillValue attribute are different.
> If you do a
>
> %> ncdump -v ucur ucur.1998.nc | less
>
> you will see many 32767 [land] and no 32766.
>
> NCL only recognizes (_FillValue) as recommended by Unidata
> and the Climate and Forecast Convention.
>
> In this case, it is the user responsibility to 'manually'
> make the change. For this dataset
>
> us@_FillValue = us@missing_value ; Force over write
> u = short2flt(us) ; convert to float
> delete(us) ; no longer needed
>
> The attached script shows the complete "fix"
>
> Good luck
>
> On 04/27/2010 01:10 AM, moon wrote:
>> Dear NCL users,
>>
>> I download GODAS monthly data from the website
>> "http://www.esrl.noaa.gov/psd/data/gridded/data.godas.html". Draw the
>> sea surface current over the dzdt, but the value over the land
>> can't be masked.
>> I think it's the problem of the missing value, delete the
>> "missing_value", but it still doesn't work.
>> Do you have any solution?
>>
>> Thank you very much.
>>
>> Regards
>> moon
>
> [SNIP]

-- ?? Opera ????????????: http://www.opera.com/mail/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: godas_2_panel.ncl
Type: application/octet-stream
Size: 4965 bytes
Desc: not available
Url :
http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20100428/45ca6642/attachment.obj

------------------------------

_______________________________________________ ncl-talk mailing list
ncl-talk@ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

End of ncl-talk Digest, Vol 77, Issue 77
****************************************
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Apr 28 07:43:06 2010

This archive was generated by hypermail 2.1.8 : Thu Apr 29 2010 - 08:05:27 MDT