<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Thanks Dave and Dennis for your suggestions. <br>
<br>
I have tried all three suggested methods, but I am getting the same
strange error message when any of these indexed substitutions is
added to my code (which works without these additions to cross the
dateline).<br>
<br>
Here are the errors returned following each suggestion:<br>
<br>
; Dennis Shea suggestion<br>
lon = f->lon<br>
lon = where(lon.lt.0, lon+360, lon) ; lon =>
0-to-360 <br>
<br>
ncendef: ncid 131072: NetCDF: One or more variable sizes violate
format constraints<br>
fatal:NetCDF: Operation not allowed in define mode: error attempting
to write variable (fishing_hours) to file (../data/Socal_GFW.nc)<br>
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 89
in file selection_by_polygon_netcdf_data.ncl<br>
<br>
ncclose: ncid 131072: NetCDF: One or more variable sizes violate
format constraints<br>
<br>
------------------------------------<br>
<br>
; Dave Allured suggestions<br>
xind = ind(lon.lt.0)<br>
lon(xind) = lon(xind) + 360 <br>
<br>
or<br>
<br>
lon(ind(lon.lt.0)) = lon(ind(lon.lt.0)) + 180 <br>
<br>
ncendef: ncid 131072: NetCDF: One or more variable sizes violate
format constraints<br>
fatal:NetCDF: Operation not allowed in define mode: error attempting
to write variable (fishing_hours) to file (../data/Socal_GFW.nc)<br>
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 89
in file selection_by_polygon_netcdf_data.ncl<br>
<br>
ncclose: ncid 131072: NetCDF: One or more variable sizes violate
format constraints<br>
----------------------------------<br>
<br>
These errors strike me as strange because the fishing hour variable
writes out just fine without the suggested additions to cross the
dateline. Do the suggested new additions also require a shift from
"define mode" before writing to netcdf? I do close the output file
after writing.<br>
<br>
Puzzled,<br>
Sam<br>
<br>
<div class="moz-cite-prefix">On 13/01/19 11:18 AM, Dennis Shea
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAOF1d_7QWr5nnjtq_WJgQ3c_H-D5C-ubZUb9QdihcEEqApss8w@mail.gmail.com">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<div dir="ltr">
<div>Rather than:</div>
<div> lon(ind(lon.lt.0)) = -lon(ind(lon.lt.0)) + 180 <br>
</div>
<div>which invokes the <b>ind</b> function<b> twice</b>, you
could do</div>
<div> ilon0 := <a
href="https://www.ncl.ucar.edu/Document/Functions/Built-in/ind.shtml"
moz-do-not-send="true"><b>ind</b></a>(lon.lt.0)</div>
<div> lon(ilon0) = -lon(ilon0) + 180</div>
<div><br>
</div>
<div>Personally, I would do the following upon input<br>
</div>
<div><br>
</div>
<div dir="ltr">lon = f->lon ; input<br>
lon =<a
href="https://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml"
moz-do-not-send="true"> <b>where</b></a>(lon.lt.0, lon+360,
lon) ; lon => 0-to-360<br>
</div>
<div dir="ltr"><br>
</div>
<div>D<br>
</div>
<div dir="ltr"><br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Sat, Jan 12, 2019 at 12:01 AM Sam McClatchie
<<a href="mailto:smcclatchie@fishocean.info"
moz-do-not-send="true">smcclatchie@fishocean.info</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF"> Colleagues<br>
<br>
I have a new question that is related to my original
question. Initially, I wanted to subset the large Global
Fishing Watch dataset into regional datasets, and then plot
the unstructured station data as fishing hours colored by
their magnitude. Rick pointed me to the gc_inout function,
and Dennis wrote some code with nested loops to do the
subsetting and plotting at the same time.<br>
<br>
This was extremely helpful, but the loops were exceedingly
slow because there are over 250,000 points per region, so I
sped up the plots by doing the subsetting with a separate
script before doing the plotting. I also figured out how to
use the new cmocean colour tables. The data, code and figure
produced are here:
<a class="gmail-m_8218959853096267226moz-txt-link-rfc2396E"
href="https://my.pcloud.com/publink/show?code=kZsanC7ZlKPCnfV5wnLFWm4C2yCww4mtUIYV"
target="_blank" moz-do-not-send="true"><https://my.pcloud.com/publink/show?code=kZsanC7ZlKPCnfV5wnLFWm4C2yCww4mtUIYV></a>.<br>
<br>
My new question is how to subset the data across the
dateline (in the New Zealand plot) when the longitude data
run from -180:180? As you can see from the plot, my plotted
fishing hours data stops at the dateline.<br>
<br>
To conveniently subset beyond 180 degrees, I tried this to
convert lon to 0:360, but I'm getting a variable unassigned
error for lon:<br>
<br>
; test
************************************************<br>
lon(ind(lon.lt.0)) = -lon(ind(lon.lt.0)) +
180 <br>
print("%%%%%%%%%%%%%%%%%%%%%%%%") <br>
printVarSummary(lon)<br>
print("%%%%%%%%%%%%%%%%%%%%%%%%") <br>
; end test
**********************************************<br>
<br>
Using the reassignment operator (:=) does not fix the
problem.<br>
<br>
Any hints would be most gratefully received.<br>
<br>
Best fishes<br>
Sam<br>
<div class="gmail-m_8218959853096267226moz-signature">-- <br>
Sam McClatchie (fisheries oceanographer)<br>
& Elena Turin (accounting & auditing)<br>
FishOcean Enterprises<br>
38 Upland Rd, Huia, Auckland 0604, New Zealand<br>
cell: 027 752 8495<br>
<span style="text-decoration:underline"><a
href="http://www.fishocean.info" target="_blank"
moz-do-not-send="true">Internet</a></span><br>
<img style="width: 150px; height: 149px;" alt=""
src="cid:part6.2DCB164C.4E2242B0@fishocean.info"
class=""><br>
<br>
"The time has come", the tui said,<br>
"to talk of many things:<br>
Of songs - and ferns - and flowering flax,<br>
of Pukekos and dreams ..."<br>
<br>
(not Lewis Carroll) </div>
</div>
</blockquote>
</div>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<meta content="text/html; charset=windows-1252"
http-equiv="content-type">
<title>email signature</title>
Sam McClatchie (fisheries oceanographer)<br>
& Elena Turin (accounting & auditing)<br>
FishOcean Enterprises<br>
38 Upland Rd, Huia, Auckland 0604, New Zealand<br>
cell: 027 752 8495<br>
<span style="text-decoration: underline;"><a
href="http://www.fishocean.info">Internet</a></span><br>
<img style="width: 150px; height: 149px;" alt=""
src="cid:part6.2DCB164C.4E2242B0@fishocean.info"><br>
<br>
"The time has come", the tui said,<br>
"to talk of many things:<br>
Of songs - and ferns - and flowering flax,<br>
of Pukekos and dreams ..."<br>
<br>
(not Lewis Carroll)
</div>
</body>
</html>