<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=UTF-8" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
        MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em; MARGIN-TOP: 0px
}
OL {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
UL {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
DIV.FoxDiv20151019123937269008 {
        COLOR: #000000
}
P {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
BODY {
        FONT-SIZE: 10.5pt; FONT-FAMILY: Microsoft YaHei UI; COLOR: #000000; LINE-HEIGHT: 1.5
}
</STYLE>
<META name=GENERATOR content="MSHTML 10.00.9200.17492"></HEAD>
<BODY style="MARGIN: 10px">
<DIV>Hi Dave,</DIV>
<DIV> </DIV>
<DIV>Thanks for your explaination. Now I know the principle of the floating
point computer arithmetic. </DIV>
<DIV>Now I realize that the results were right and the rounding error were
acceptable.</DIV>
<DIV> </DIV>
<DIV>Thanks again.</DIV>
<DIV> </DIV>
<DIV>Huansheng </DIV>
<DIV> </DIV>
<HR style="HEIGHT: 1px; WIDTH: 210px" align=left color=#b5c4df SIZE=1>
<DIV><SPAN>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: verdana; MARGIN: 10px">
<DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: verdana; MARGIN: 10px">
<DIV>陈焕盛(LAPC/IAP)</DIV>
<DIV>大气边界层物理和大气化学国家重点实验室</DIV>
<DIV>中国科学院大气物理研究所</DIV></DIV></DIV></DIV></SPAN></DIV>
<DIV> </DIV>
<DIV
style="BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; BORDER-BOTTOM: medium none; PADDING-BOTTOM: 0cm; PADDING-TOP: 3pt; PADDING-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm">
<DIV
style="FONT-SIZE: 12px; FONT-FAMILY: tahoma; BACKGROUND: #efefef; COLOR: #000000; PADDING-BOTTOM: 8px; PADDING-TOP: 8px; PADDING-LEFT: 8px; PADDING-RIGHT: 8px">
<DIV><B>From:</B> <A href="mailto:dave.allured@noaa.gov">Dave Allured -
NOAA Affiliate</A></DIV>
<DIV><B>Date:</B> 2015-10-19 06:38</DIV>
<DIV><B>To:</B> <A
href="mailto:chenhuansheng@mail.iap.ac.cn">chenhuansheng@mail.iap.ac.cn</A></DIV>
<DIV><B>CC:</B> <A href="mailto:haley@ucar.edu">Mary Haley</A>; <A
href="mailto:ncl-talk@ucar.edu">ncl-talk</A></DIV>
<DIV><B>Subject:</B> Re: [ncl-talk] question to the NCL latlon_to_SCRIP
function</DIV></DIV></DIV>
<DIV>
<DIV class=FoxDiv20151019123937269008 style="BACKGROUND-COLOR: white">
<DIV dir=ltr>
<DIV>Huansheng Chen,<BR></DIV>
<DIV><BR></DIV>
<DIV>The number 0.1 does not have an exact representation in regular floating
point computer arithmetic. The closest possible floating point numbers are
approximately 0.10000000149 (single precision), or 0.10000000000000000555
(double precision).</DIV>
<DIV><BR></DIV>
<DIV>Therefore, it is impossible to create numeric arrays with exactly 0.1
degree intervals.</DIV>
<DIV><BR></DIV>
<DIV>The cases for 1.0, 0.5 and 0.25 degree intervals are different, because
each of these numbers has an exact representation in floating point
arithmetic.<BR><BR>Please read this section on Wikipedia. The discussion
uses 0.1 as an example, the same interval that you want:</DIV>
<DIV><BR></DIV><A
href="https://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_rounding"
target=_blank>https://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_rounding</A>
<DIV><BR></DIV>
<DIV>Also note that your original end points (89.95d, 179.95d) do not have exact
floating point representations.<BR>
<DIV><BR></DIV>
<DIV>The best you can do is to make a set of approximate numbers that matches
what you need in some way. Can you restate your problem in terms of how
you want to fit your interval and end points to a theoretical set of
numbers?</DIV>
<DIV><BR></DIV>
<DIV>--Dave</DIV>
<DIV><BR></DIV>
<DIV class=gmail_extra><BR>
<DIV class=gmail_quote>On Sun, Oct 18, 2015 at 3:50 AM, <A
href="mailto:chenhuansheng@mail.iap.ac.cn"
target=_blank>chenhuansheng@mail.iap.ac.cn</A> <SPAN dir=ltr><<A
href="mailto:chenhuansheng@mail.iap.ac.cn"
target=_blank>chenhuansheng@mail.iap.ac.cn</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"><U></U>
<DIV style="MARGIN: 10px">
<DIV>Hi Mary,</DIV>
<DIV> </DIV>
<DIV>I tried "<A
href="mailto:Opt@URCorner%C2%A0%C2%A0=+(/+%C2%A089.97d,+%C2%A0179.97d/)"
target=_blank>Opt@URCorner = (/ 89.97d, 179.97d/)</A>",
this resulted in "grid_dims = 3600, 1800".</DIV>
<DIV>However, the lat-lon intervals are not exactly 0.1 degree. </DIV>
<DIV style="COLOR: rgb(255,0,0)">For example: "grid_center_lon = -179.95,
-179.849994442901, -179.749988885802, "</DIV>
<DIV style="COLOR: rgb(255,0,0)">It should be "grid_center_lon = -179.95,
-179.85, -179.75, "</DIV>
<DIV> </DIV>
<DIV>I also tried "<A
href="mailto:Opt@URCorner%C2%A0%C2%A0=+(/+%C2%A089.95001d,+%C2%A0179.95001d/)"
target=_blank>Opt@URCorner = (/ 89.95001d,
179.95001d/)</A>", the problem was similar.</DIV>
<DIV>"grid_center_lon = -179.95, -179.849999997221, -179.749999994443, "</DIV>
<DIV> </DIV>
<DIV>The results I want are the 0.1x0.1 grids with exactly equal latitude and
longtitude intervals (0.1 degree). How can I get it ?</DIV>
<DIV>For the 0.25x0.25 grids, the output results are right.<BR></DIV>
<DIV>Best Wishes,</DIV>
<DIV>Huansheng</DIV>
<DIV> </DIV>
<HR style="MIN-HEIGHT: 1px; WIDTH: 210px" align=left color=#b5c4df SIZE=1>
<DIV><SPAN>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: verdana; MARGIN: 10px">
<DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: verdana; MARGIN: 10px">
<DIV>陈焕盛(LAPC/IAP)</DIV>
<DIV>大气边界层物理和大气化学国家重点实验室</DIV>
<DIV>中国科学院大气物理研究所</DIV></DIV></DIV></DIV></SPAN></DIV>
<DIV> </DIV>
<DIV
style="BORDER-TOP: rgb(181,196,223) 1pt solid; BORDER-RIGHT: medium none; BORDER-BOTTOM: medium none; PADDING-BOTTOM: 0cm; PADDING-TOP: 3pt; PADDING-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm">
<DIV
style="FONT-SIZE: 12px; FONT-FAMILY: tahoma; COLOR: rgb(0,0,0); PADDING-BOTTOM: 8px; PADDING-TOP: 8px; PADDING-LEFT: 8px; PADDING-RIGHT: 8px; BACKGROUND-COLOR: rgb(239,239,239)">
<DIV><B>From:</B> <A href="mailto:haley@ucar.edu" target=_blank>Mary
Haley</A></DIV>
<DIV><B>Date:</B> 2015-10-17 00:47</DIV>
<DIV><B>To:</B> <A href="mailto:chenhuansheng@mail.iap.ac.cn"
target=_blank>chenhuansheng@mail.iap.ac.cn</A></DIV>
<DIV><B>CC:</B> <A href="mailto:ncl-talk@ucar.edu"
target=_blank>ncl-talk</A></DIV>
<DIV><B>Subject:</B> Re: [ncl-talk] question to the NCL latlon_to_SCRIP
function</DIV></DIV></DIV>
<DIV>
<DIV style="BACKGROUND-COLOR: white">
<DIV dir=ltr>
<DIV style="FONT-SIZE: small">It looks like a simple rounding error.
</DIV>
<DIV style="FONT-SIZE: small"><BR></DIV>
<DIV style="FONT-SIZE: small">By providing strict corner lat/lon boundary
values and a small resolution, you end up with values like 89.950001 and
179.950001. These are out of range of the URCorner boundary values that you
provided, so you then end up with the last two values removed. </DIV>
<DIV style="FONT-SIZE: small"><BR></DIV>
<DIV style="FONT-SIZE: small">You can try using slightly a higher values for
URCorner:</DIV>
<DIV style="FONT-SIZE: small"><BR></DIV>
<DIV style="FONT-SIZE: small">
<DIV>Opt@URCorner = (/ 89.97d,
179.97d/)<BR></DIV>
<DIV><BR></DIV>
<DIV>I've created a ticket (NCL-2293) on this to see if this is something we
can improve.</DIV>
<DIV><BR></DIV>
<DIV>--Mary</DIV>
<DIV><BR></DIV></DIV></DIV>
<DIV class=gmail_extra><BR>
<DIV class=gmail_quote>On Fri, Oct 16, 2015 at 1:13 AM, <A
href="mailto:chenhuansheng@mail.iap.ac.cn"
target=_blank>chenhuansheng@mail.iap.ac.cn</A> <SPAN dir=ltr><<A
href="mailto:chenhuansheng@mail.iap.ac.cn"
target=_blank>chenhuansheng@mail.iap.ac.cn</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"><U></U>
<DIV style="MARGIN: 10px">
<DIV>
<DIV>Dear all,</DIV>
<DIV> </DIV>
<DIV>I used the latlon_to_SCRIP function to
generate lat-lon grid file with SCRIP format which will then be
used as input files of the ESMF application "ESMF_RegridWeightGen".</DIV>
<DIV>When I applied latlon_to_SCRIP to 1x1, 0.5x0.5 and 0.25x0.25
grids, the output results were right. However, when I applied
latlon_to_SCRIP to 0.1x0.1 grids, the output results </DIV>
<DIV>are wrong. Do the latlon_to_SCRIP function support to generate a
0.1x0.1 grid file? Can you help me to solve this problem? </DIV>
<DIV>Thank you very much.</DIV>
<DIV> </DIV>
<DIV style="COLOR: rgb(255,0,0)">The code used to generate the
0.25x0.25 grids are as follows:</DIV>
<DIV>_______________</DIV>
<DIV>
<DIV>Opt
= True</DIV>
<DIV><A href="mailto:Opt@LLCorner"
target=_blank>Opt@LLCorner</A> = (/
-89.875d, -179.875d/)</DIV>
<DIV><A href="mailto:Opt@URCorner"
target=_blank>Opt@URCorner</A> =
(/ 89.875d, 179.875d/)</DIV>
<DIV><A href="mailto:Opt@ForceOverwrite"
target=_blank>Opt@ForceOverwrite</A> = True</DIV>
<DIV><A href="mailto:Opt@PrintTimings"
target=_blank>Opt@PrintTimings</A> = True</DIV>
<DIV>latlon_to_SCRIP(srcGridName,"0.25x0.25",Opt)</DIV>
<DIV>delete(Opt)</DIV>
<DIV>________________</DIV>
<DIV> </DIV></DIV>
<DIV style="COLOR: rgb(255,0,0)">The header of the output netcdf file is as
follows: </DIV>
<DIV>________________</DIV>
<DIV>
<DIV>dimensions:</DIV>
<DIV> grid_size = 1036800 ;</DIV>
<DIV> grid_corners = 4 ;</DIV>
<DIV> grid_rank = 2 ;</DIV>
<DIV>variables:</DIV>
<DIV> int grid_dims(grid_rank)
;</DIV>
<DIV> double
grid_center_lat(grid_size) ;</DIV>
<DIV>
grid_center_lat:units = "degrees" ;</DIV>
<DIV> double
grid_center_lon(grid_size) ;</DIV>
<DIV>
grid_center_lon:units = "degrees" ;</DIV>
<DIV> int grid_imask(grid_size)
;</DIV>
<DIV>
grid_imask:units = "unitless" ;</DIV>
<DIV> double
grid_corner_lat(grid_size, grid_corners) ;</DIV>
<DIV>
grid_corner_lat:units = "degrees" ;</DIV>
<DIV> double
grid_corner_lon(grid_size, grid_corners) ;</DIV>
<DIV>
grid_corner_lon:units = "degrees" ;</DIV>
<DIV> </DIV>
<DIV>// global attributes:</DIV>
<DIV>
:date_created = "Thu Oct 15 19:49:54 CST 2015" ;</DIV>
<DIV>
:Createdby = "ESMF_regridding.ncl" ;</DIV>
<DIV>
:Conventions = "SCRIP" ;</DIV>
<DIV>
:title = "0.25x0.25 grid" ;</DIV>
<DIV>data:</DIV>
<DIV> </DIV>
<DIV>grid_dims = 1440, 720 ;</DIV></DIV>
<DIV>________________</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>
<DIV style="COLOR: rgb(255,0,0)">The code used to generate the 0.1x0.1
grids are as follows:</DIV></DIV>
<DIV>
<DIV>_______________</DIV>
<DIV>
<DIV>Opt
= True</DIV>
<DIV><A href="mailto:Opt@LLCorner"
target=_blank>Opt@LLCorner</A> = (/
-89.95d, -179.95d/)</DIV>
<DIV><A href="mailto:Opt@URCorner"
target=_blank>Opt@URCorner</A> =
(/ 89.95d, 179.95d/)</DIV>
<DIV><A href="mailto:Opt@ForceOverwrite"
target=_blank>Opt@ForceOverwrite</A> = True</DIV>
<DIV><A href="mailto:Opt@PrintTimings"
target=_blank>Opt@PrintTimings</A> = True</DIV>
<DIV>latlon_to_SCRIP(srcGridName,"0.1x0.1",Opt)</DIV>
<DIV>delete(Opt)</DIV>
<DIV>________________</DIV>
<DIV> </DIV>
<DIV style="COLOR: rgb(255,0,0)">The header of the output netcdf file is as
follows: </DIV></DIV></DIV>
<DIV>_____________</DIV>
<DIV>
<DIV>dimensions:</DIV>
<DIV> grid_size = 6474601 ;</DIV>
<DIV> grid_corners = 4 ;</DIV>
<DIV> grid_rank = 2 ;</DIV>
<DIV>variables:</DIV>
<DIV> int grid_dims(grid_rank)
;</DIV>
<DIV> double
grid_center_lat(grid_size) ;</DIV>
<DIV>
grid_center_lat:units = "degrees" ;</DIV>
<DIV> double
grid_center_lon(grid_size) ;</DIV>
<DIV>
grid_center_lon:units = "degrees" ;</DIV>
<DIV> int grid_imask(grid_size)
;</DIV>
<DIV>
grid_imask:units = "unitless" ;</DIV>
<DIV> double
grid_corner_lat(grid_size, grid_corners) ;</DIV>
<DIV>
grid_corner_lat:units = "degrees" ;</DIV>
<DIV> double
grid_corner_lon(grid_size, grid_corners) ;</DIV>
<DIV>
grid_corner_lon:units = "degrees" ;</DIV>
<DIV> </DIV>
<DIV>// global attributes:</DIV>
<DIV>
:date_created = "Thu Oct 15 20:27:42 CST 2015" ;</DIV>
<DIV>
:Createdby = "ESMF_regridding.ncl" ;</DIV>
<DIV>
:Conventions = "SCRIP" ;</DIV>
<DIV>
:title = "0.1deg grid" ;</DIV>
<DIV>data:</DIV>
<DIV> </DIV>
<DIV>grid_dims = 3599, 1799 ;</DIV></DIV>
<DIV>_____________</DIV>
<DIV style="FONT-WEIGHT: bold; COLOR: rgb(255,0,0)">Why the grid_dims are
3599x1799? I think it should be 3600x1800.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Yours Sincerely,</DIV>
<DIV>Huansheng Chen</DIV></DIV>
<DIV> </DIV>
<HR style="MIN-HEIGHT: 1px; WIDTH: 210px" align=left color=#b5c4df SIZE=1>
<DIV><SPAN>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: verdana; MARGIN: 10px">
<DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: verdana; MARGIN: 10px">
<DIV>陈焕盛(LAPC/IAP)</DIV>
<DIV>大气边界层物理和大气化学国家重点实验室</DIV>
<DIV>中国科学院大气物理研究所</DIV></DIV></DIV></DIV></SPAN></DIV></DIV></BLOCKQUOTE></DIV></DIV></DIV></DIV></DIV></BLOCKQUOTE></DIV></DIV></DIV></DIV></DIV></DIV></BODY></HTML>