<div dir="ltr">I want to add that funny _FillValue is probably the result of writing &quot;-999.9&quot; somewhere in source code, then converting it from single to double precision in a separate operation.  This is a common mistake.  This is NOT the same value as &quot;-999.9d&quot; or equivalent in NCL, IDL, or many other other languages.<br><br>ncl 0&gt; a = todouble (-999.9)<br>ncl 1&gt; b = -999.9d<br><br>ncl 2&gt; print (sprintf (&quot;%20.13f&quot;, a))   <br>(0)       -999.9000244140625<br>ncl 3&gt; print (sprintf (&quot;%20.13f&quot;, b))  <br>(0)       -999.9000000000000<div class="gmail_extra"><br></div><div class="gmail_extra">I agree with Dave Brown&#39;s observations and suggested method to read.  He sets the _FillValue with the maximum necessary number of significant digits for type double.  Otherwise NCL would not understand all the missing values.</div><div class="gmail_extra"><br></div><div class="gmail_extra">--Dave A.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 30, 2017 at 3:55 PM, David Brown <span dir="ltr">&lt;<a href="mailto:dbrown@ucar.edu" target="_blank">dbrown@ucar.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">My guess is that this file is a 2D 720 x 1440 array of doubles in<br>
little endian format. There is no specific IDL formatting.<br>
The file size is 8294400 which is exactly equal to 720 x 1440 x 8. It<br>
contains may NaNs (not a number) and it also has what is presumably a<br>
_FillValue with the value -999.9000244140625.<br>
<br>
Here&#39;s how I would read it:<br>
<br>
setfileoption(&quot;bin&quot;,&quot;<wbr>ReadByteOrder&quot;,&quot;LittleEndian&quot;)<br>
d1 = cbinread(&quot;viirs_meandbdi_<wbr>gridded_statis2015002.dat&quot;,-1,<wbr>&quot;double&quot;)<br>
<br>
Make an array of all the non-nan values (otherwise printMinMax will<br>
return NaN for both min and max)<br>
d1ind = ind(.not. isnan_ieee(d1))<br>
d1x = d1(d1ind)<br>
printMinMax(d1x,0)<br>
  output: (0)     min=-999.9000244140625   max=5.164013057067244<br>
<br>
If you scroll through the variable d1x values you will see that the<br>
min value is clearly an outlier and therefore is most likely a fill<br>
value.<br>
So set the _FillValue<br>
d1x@_FillValue = -999.9000244140625<br>
Now<br>
printMinMax(d1x,0)<br>
   output: (0)     min=0.2350846065940295   max=5.164013057067244<br>
<br>
Hopefully these are reasonable values.<br>
<br>
Now set the _FillValue for the original data and turn the NaNs into _FillValue<br>
d1@_FillValue = d1x@_FillValue<br>
d1 = where(isnan_ieee(d1),d1@_<wbr>FillValue, d1)<br>
ncl 73&gt; printMinMax(d1,0)<br>
(0)     min=0.2350846065940295   max=5.164013057067244<br>
<br>
But note out of the whole array there are not very many valid values:<br>
<br>
ncl 74&gt; printVarSummary(d1)<br>
Variable: d1<br>
Type: double<br>
Total Size: 8294400 bytes<br>
            1036800 values<br>
Number of Dimensions: 1<br>
Dimensions and sizes: [1036800]<br>
Coordinates:<br>
Number Of Attributes: 1<br>
  _FillValue : -999.9000244140625<br>
<br>
ncl 75&gt; print(num(.not. ismissing(d1)))<br>
(0)     1820<br>
<br>
Nevertheless I believe this is the correct interpretation of this dataset.<br>
 -dave<br><br>
<br>
On Thu, Mar 30, 2017 at 2:29 PM, Debasish Hazra<br>
&lt;<a href="mailto:debasish.hazra5@gmail.com">debasish.hazra5@gmail.com</a>&gt; wrote:<br>
&gt; Thanks Gus. Mary and myself both tried &quot;endian&quot; options, and presently<br>
&gt; trying with<br>
&gt;<br>
&gt; &quot;setfileoption(&quot;bin&quot;,&quot;<wbr>readbyteorder&quot;,&quot;bigendian&quot;) option which seems to<br>
&gt; produce reasonable minimum and maximum of data values. However, as Mary<br>
&gt; mentioned large number of values are constant whcih is bit strange.<br>
&gt;<br>
&gt; You mentioned about &quot;double&quot; and I think input is in &quot;double precision<br>
&gt; floating point data and it is 8 bytes&quot;.<br>
&gt;<br>
&gt; Thanks.<br>
&gt; Debasish<br>
&gt;<br>
&gt; On Thu, Mar 30, 2017 at 4:06 PM, Gus Correa &lt;<a href="mailto:gus@ldeo.columbia.edu">gus@ldeo.columbia.edu</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi Mary, Debasish<br>
&gt;&gt;<br>
&gt;&gt; Could it be a little-endian vs. big-endian issue?<br>
&gt;&gt; I don&#39;t know IDL (I should! My boss uses it! :) )<br>
&gt;&gt; but their &quot;read_binary&quot; default endianness is &quot;native&quot; (like NCL).<br>
&gt;&gt; I.e., the endianness of the data on the file depends on the<br>
&gt;&gt; machine it was created (and data_type=5 is indeed double precision).<br>
&gt;&gt;<br>
&gt;&gt; Maybe using setfileoption(&#39;bin&#39;,&quot;<wbr>ReadByteOrder&quot;,&quot;BigEndian&quot;),<br>
&gt;&gt; and trying also &quot;LittleEndian&quot; if not lucky with &quot;Big&quot;<br>
&gt;&gt; (who knows where the file was written ....),<br>
&gt;&gt; then cbinread/fbindirread with datatype &quot;double&quot; would help?<br>
&gt;&gt; Just a guess, and you probably tried the endianness thing already ...<br>
&gt;&gt;<br>
&gt;&gt; Best,<br>
&gt;&gt; Gus Correa<br>
&gt;&gt;<br>
&gt;&gt; On 03/30/2017 02:54 PM, Mary Haley wrote:<br>
&gt;&gt; &gt; Hi Debasish,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Dennis guess that maybe the &quot;read_binary&quot; function in IDL was meant to<br>
&gt;&gt; &gt; read files created by &quot;write_binary&quot; but I didn&#39;t see a function with<br>
&gt;&gt; &gt; that name. However, is it possible that this is some kind of special IDL<br>
&gt;&gt; &gt; file and not a flat C binary file?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; In your IDL script, you have:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; fdata=read_binary(&#39;viirs_<wbr>meandbdi_gridded_statis2013&#39;+<wbr>day+&#39;.dat&#39;,data_type=5,data_<wbr>dims=[1440,720])<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; If you read the documentation for &quot;read_binary&quot;, it states that<br>
&gt;&gt; &gt; &quot;data_type=5&quot; is double.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; In your NCL script, you are reading the data as an unsigned integer.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I tried reading your data as a double, but I get what looks like<br>
&gt;&gt; &gt; nonsensical values:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;  min=-1.642556686681977e+308   max=6.633924105807938e+307<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; You are right that the unsigned integer values look reasonable, but only<br>
&gt;&gt; &gt; after you multiply them by 1e-9.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; When I look at your unsigned values, I see that<br>
&gt;&gt; &gt; 517,484<br>
&gt;&gt; &gt; of your values are equal to the same number: 6.3615e-05, while only<br>
&gt;&gt; &gt; 1,831<br>
&gt;&gt; &gt;  values are equal to something else.<br>
&gt;&gt; &gt; This seems a bit suspicious to me, and is likely the source of the<br>
&gt;&gt; &gt; problem.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I modified your script to plot red markers where the values are all<br>
&gt;&gt; &gt; equal to 6.3615e-05, and black markers everywhere else. Does this look<br>
&gt;&gt; &gt; correct?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I have a feeling that there&#39;s something more to the &quot;read_binary&quot;<br>
&gt;&gt; &gt; function that we need to know in order to read the file correctly.  As I<br>
&gt;&gt; &gt; think I mentioned before: perhaps each byte of data represents something<br>
&gt;&gt; &gt; different, and you need to use something like dim_gbits to pick off<br>
&gt;&gt; &gt; values.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; In your IDL script, is there anything you have to do additionally to the<br>
&gt;&gt; &gt; data before you plot it?  Can you check the IDL script to see if you are<br>
&gt;&gt; &gt; getting a lot of values equal to the same constant value that NCL is?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; --Mary<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Thu, Mar 30, 2017 at 8:36 AM, Debasish Hazra<br>
&gt;&gt; &gt; &lt;<a href="mailto:debasish.hazra5@gmail.com">debasish.hazra5@gmail.com</a> &lt;mailto:<a href="mailto:debasish.hazra5@gmail.com">debasish.hazra5@gmail.<wbr>com</a>&gt;&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;     Mary,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;     Thanks.Taking your suggestion and reading that as 2 * 720 * 1440 and<br>
&gt;&gt; &gt;     assuming input as C binary file, I am getting      min=1.4e-08<br>
&gt;&gt; &gt;     max=4.29371 , which is reasonble. Attached is the new script. Any<br>
&gt;&gt; &gt;     suggestions.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;     Debasish<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;     On Wed, Mar 29, 2017 at 5:28 PM, Mary Haley &lt;<a href="mailto:haley@ucar.edu">haley@ucar.edu</a><br>
&gt;&gt; &gt;     &lt;mailto:<a href="mailto:haley@ucar.edu">haley@ucar.edu</a>&gt;&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         Hi Debasish,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         Kevin and I took a look at this. For starters, there *is* an<br>
&gt;&gt; &gt;         error message coming out of your script:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         warning:cbinread: The size implied by the dimension arrays is<br>
&gt;&gt; &gt;         greater that the size of the file.<br>
&gt;&gt; &gt;          The default _FillValue for the specified type will be filled in.<br>
&gt;&gt; &gt;          Note dimensions and values may not be aligned properly<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         If you look at the size of the file, it doesn&#39;t match with the<br>
&gt;&gt; &gt;         dimensions you&#39;re requesting:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         Size of file = 8294400 bytes<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         Size of dimensions = 5 * 720 * 1440 * 4 (for a uint) = 20736000<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         If this is truly a C binary file, it looks like it only has 2 *<br>
&gt;&gt; &gt;         720 * 1440 * 4 bytes.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         This doesn&#39;t really change the results, however, because you<br>
&gt;&gt; &gt;         still get two strange looking plots.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         We tried several different things:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         1) reading the data as ubyte, int, and ushort<br>
&gt;&gt; &gt;         2) reversing the array to 1440 x 720 x 2<br>
&gt;&gt; &gt;         3) reading the data as little endian<br>
&gt;&gt; &gt;         4) plotting the data as a simple contour plot to take out the<br>
&gt;&gt; &gt;         map component.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         Nothing we did produced more information about the file, or<br>
&gt;&gt; &gt;         produced better plots.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         Is there some documentation on this file to understand how it<br>
&gt;&gt; &gt;         was written? For example, are you sure the &quot;uint&quot; type is<br>
&gt;&gt; &gt;         correct? Are you sure the dimension sizes are correct? Why are<br>
&gt;&gt; &gt;         the values so large? Is it possible that this is &quot;packed&quot; data,<br>
&gt;&gt; &gt;         and that you need to use a function like dim_gbits to pick off<br>
&gt;&gt; &gt;         individual bits of information?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         If you can find a C or Fortran code that was used to create this<br>
&gt;&gt; &gt;         file, then it should be fairly straightforward to figure out how<br>
&gt;&gt; &gt;         to read it.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         --Mary<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         On Wed, Mar 29, 2017 at 2:18 PM, Debasish Hazra<br>
&gt;&gt; &gt;         &lt;<a href="mailto:debasish.hazra5@gmail.com">debasish.hazra5@gmail.com</a> &lt;mailto:<a href="mailto:debasish.hazra5@gmail.com">debasish.hazra5@gmail.<wbr>com</a>&gt;&gt;<br>
&gt;&gt; &gt;         wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;             Hi,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;             I am trying to read a binary file with the attached code,<br>
&gt;&gt; &gt;             but  getting all empty fields in the figure with no apparent<br>
&gt;&gt; &gt;             error message. Uploaded  the data file in the ftp server<br>
&gt;&gt; &gt;             &quot;viirs_meandbdi_gridded_<wbr>statis2015048.dat&quot;. Any help with<br>
&gt;&gt; &gt;             this is appreciated.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;             Thanks.<br>
&gt;&gt; &gt;             Debasish<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;             On Wed, Mar 22, 2017 at 10:33 AM, Debasish Hazra<br>
&gt;&gt; &gt;             &lt;<a href="mailto:debasish.hazra5@gmail.com">debasish.hazra5@gmail.com</a><br>
&gt;&gt; &gt;             &lt;mailto:<a href="mailto:debasish.hazra5@gmail.com">debasish.hazra5@gmail.<wbr>com</a>&gt;&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;                 Hi,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;                 I am trying to read a binary file with the attached<br>
&gt;&gt; &gt;                 code, but  getting all empty fields in the figure with<br>
&gt;&gt; &gt;                 no apparent error message. Uploaded  the data file in<br>
&gt;&gt; &gt;                 the ftp server<br>
&gt;&gt; &gt;                 &quot;viirs_meandbdi_gridded_<wbr>statis2015002.dat&quot;. Any help<br>
&gt;&gt; &gt;                 with this is appreciated.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;                 Thanks.<br>
&gt;&gt; &gt;                 Debasish.<br></blockquote></div></div></div>