[ncl-talk] station data/ ascii to nc/ subsetting problem

Dennis Shea shea at ucar.edu
Thu Jan 3 16:57:04 MST 2019


Oops!  Sorry about that!  Try again   :-)

I'm sure improvements can be made but this will have to do.

HTH
D

On Thu, Jan 3, 2019 at 4:49 PM Dennis Shea <shea at ucar.edu> wrote:

> See attached script and png.
>
> HTH, D
>
> On Wed, Jan 2, 2019 at 8:32 PM Sam McClatchie <smcclatchie at fishocean.info>
> wrote:
>
>> Colleagues
>>
>> Thanks for pointing out the gc_inout function, Rick. My regions are
>> currently simple shape files.
>>
>> The function gc_inout is working for me (please see test code and test
>> data at
>> <https://my.pcloud.com/publink/show?code=kZsanC7ZlKPCnfV5wnLFWm4C2yCww4mtUIYV>
>> <https://my.pcloud.com/publink/show?code=kZsanC7ZlKPCnfV5wnLFWm4C2yCww4mtUIYV>).
>> But now I have what I think is a simple problem that I have not solved. How
>> to subset the data variables based on the logical variable produced by
>> gs_inout? I have tried to do so using a looped conditional statement, but
>> there is a problem with the indexed assignment as I have written it. I'm
>> also expecting that a loop like this will be way to slow for the large data
>> size I have. There must be a smarter way to do this, but in reading the
>> manuals and help files, I'm still missing it.
>>
>> Any hints would be useful.
>>
>> Thanks, Sam
>>
>> On 28/12/18 2:44 AM, Rick Brownrigg wrote:
>>
>> Hi Sam,
>>
>> You might take a look at the gc_inout  function. Not sure how you are
>> defining your regions - shapefiles? Simple bounding boxes?
>>
>> Rick
>>
>> On Tuesday, December 25, 2018, Sam McClatchie <smcclatchie at fishocean.info>
>> wrote:
>>
>>> Colleagues
>>>
>>> I have some voluminous station data in ascii files that I have written
>>> into a netcdf file with minimal pre-definition of dimensions and attributes
>>> (please see the link below for the data and code). My problem is that I
>>> want to subset the global fishing_hours variable conveniently by region.
>>>
>>> The obvious solution would be to dimension the fishing_hours variable
>>> properly into a 3-dimensional variable (time, lat, lon) and use named
>>> coordinate subscripting. I realised when I went back to rewrite the data
>>> with variable pre-definition that I have a problem, because these data are
>>> not on any kind of grid, so the sizes of the coordinate arrays are the same
>>> size as the vector lengths for lat/ lon.
>>>
>>> My goal is to plot fishing_hours on maps where each point is
>>> colour-coded by the magnitude of the fishing_hours variable (as for
>>> example, here: <see
>>> https://www.ncl.ucar.edu/Applications/Scripts/station_2.ncl>). Note
>>> that the data were not subset, I simply set the map regions. Also, the plot
>>> only shows lat/lon variables, not the fishing_hours variable because it has
>>> no coordinate variables.
>>>
>>> The data, NCL code, and figure referred to in this message can be
>>> downloaded from here:
>>> <https://my.pcloud.com/publink/show?code=kZsanC7ZlKPCnfV5wnLFWm4C2yCww4mtUIYV>
>>> <https://my.pcloud.com/publink/show?code=kZsanC7ZlKPCnfV5wnLFWm4C2yCww4mtUIYV>
>>> I suggest downloading the directory as an archive and unpacking it
>>> locally to a scratch directory.
>>>
>>> Any help on how to conveniently subset the global fishing_hours data by
>>> lat/ lon would be appreciated.
>>>
>>> Best fishes
>>> Sam
>>>
>>
>> --
>> Sam McClatchie (fisheries oceanographer)
>> & Elena Turin (accounting & auditing)
>> FishOcean Enterprises
>> 38 Upland Rd, Huia, Auckland 0604, New Zealand
>> cell: 027 752 8495
>> Internet <http://www.fishocean.info>
>>
>>
>> "The time has come", the tui said,
>> "to talk of many things:
>> Of songs - and ferns - and flowering flax,
>> of Pukekos and dreams ..."
>>
>> (not Lewis Carroll)
>> _______________________________________________
>> 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/20190103/1db8ee9a/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SamMcClatchie2_small.jpg
Type: image/jpeg
Size: 45362 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190103/1db8ee9a/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_concatenated_fishing_effort.NEW.ncl
Type: application/octet-stream
Size: 6285 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190103/1db8ee9a/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_concatenated_fishing_effort.png
Type: image/png
Size: 142959 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190103/1db8ee9a/attachment-0002.png>


More information about the ncl-talk mailing list