[ncl-talk] re-order array by time dimension

Mary Haley haley at ucar.edu
Mon May 8 15:57:11 MDT 2017


Hi Andrew,

Thanks for the providing the files.

I took your script and heavily modified it to just read time and
temperature off all the files, so I could see what was going on with time.

It appears that your time variable is non-monotonic *in each individual
file*, which violates coordinate array rules. NCL will still read it in,
but will give you a warning about the non-monotonic arrays:

warning:Aggregated dimension coordinate values are non-monotonic; check
aggregated file ordering

See the attached hamsr_time.ncl, which you can run to see how each time
array on each file is non-monotonic.

You were almost there there with trying to reorder the time dimension.

What you need to do is call dim_pqsort to return the permutation vector
needed to sort time:

;--- return permutation vector for sorting time
                                ip = dim_pqsort(temp_hamsr&time,1)

and then use "ip" to sort both temp_hamsr *and* the time coordinate array
with one call:


temp_hamsr_reorder = temp_hamsr(ip,:)  ; this reorders both temp_hamsr and
temp_hamsr&time


I created a separate script (plot_temp_hamsur_before_after.ncl) that just
reads in temp across all files, and then I plotted this variable both
before and after the time array had been sorted.

You will notice some lines crossing each other in the before plot. This is
because the time values were not monotonic.

There are still some "jumps" in time, but this is probably because time is
somewhat irregular in the spacing.

Hopefully this makes sense.

--Mary


On Mon, May 8, 2017 at 7:11 AM, Andrew Kren - NOAA Affiliate <
andrew.kren at noaa.gov> wrote:

> Hi Mary,
> I think I uploaded the files there now. I ran into a few issues putting
> them on there but I think it is fixed. Let me know if they are there, they
> should be listed as HAMSR*.nc
>
> Thanks,
>
> On Thu, May 4, 2017 at 4:27 PM, Mary Haley <haley at ucar.edu> wrote:
>
>> Hi Andrew,
>>
>> It would help if we could see a sample of your files so we can understand
>> how the time dimension is getting out of order.
>>
>> Can you provide a subset of them or even all of them? I can see that
>> there might be issues when you are talking about data that is being
>> collected at the seconds level.
>>
>> If you just have a few files, or if they are not too large, then you can
>> use our ftp:
>>
>>     ftp ftp.cgd.ucar.edu
>>     <log in as "anonymous">
>>     <Use email address as password>
>>     cd incoming
>>     put <your files>
>>     quit
>>
>> You can do this offline if you prefer.
>>
>> Thanks,
>>
>> --Mary
>>
>>
>>
>> On Thu, May 4, 2017 at 8:05 AM, Andrew Kren - NOAA Affiliate <
>> andrew.kren at noaa.gov> wrote:
>>
>>> Dear ncl-talk,
>>>
>>> I have data on airborne temperature and moisture retrievals. This data
>>> comes in netcdf format with output every 1-2 seconds. The data is binned
>>> into hourly netcdf files. I read in the data using addfiles so that I can
>>> store all of it together instead of looping over each one. I want to
>>> compare and average this data around the time of a dropsonde release. When
>>> I read in the data, the time dimension gets out of order and is not in
>>> increasing time. I have tried to do qsort and dim_pqsort_n in conjunction
>>> with example 3 here (https://www.ncl.ucar.edu/Docu
>>> ment/Functions/Built-in/dim_pqsort_n.shtml), but for some reason I
>>> can't find out how to re-order my temperature and moisture data along the
>>> time dimension.
>>>
>>> My temperature and moisture data has format of (time, level). Any help
>>> is much appreciated, and attached is my ncl script.
>>>
>>> Thanks,
>>>
>>> --
>>> Andrew Kren, PhD
>>> Research Scientist I, Global Observing Systems Analysis (GOSA) Group
>>> NOAA ESRL Global Systems Division (Rm 3C515)
>>> 325 Broadway, Boulder, CO 80305
>>> (303) 497-5418
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
>
> --
> Andrew Kren, PhD
> Research Scientist I, Global Observing Systems Analysis (GOSA) Group
> NOAA ESRL Global Systems Division (Rm 3C515)
> 325 Broadway, Boulder, CO 80305
> (303) 497-5418
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170508/eb7f3fdd/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hamsr.png
Type: image/png
Size: 187316 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170508/eb7f3fdd/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hamsr_time.ncl
Type: application/octet-stream
Size: 321 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170508/eb7f3fdd/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_temp_hamsur_before_after.ncl
Type: application/octet-stream
Size: 1923 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170508/eb7f3fdd/attachment-0001.obj 


More information about the ncl-talk mailing list