[GRASS-dev] [GRASS GIS] #2941: r.sun: wrong sign in equation of time

#2941: r.sun: wrong sign in equation of time
-------------------------+-------------------------
Reporter: tomhuld | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.4
Component: Default | Version: unspecified
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
Bug report ticket #2876 by fabriziosossan reported a problem with the
equation of time in r.sun, whereby the calculation of the solar time from
the clock (civil) time is wrong. The problem was fixed with a patch for
GRASS 6, but as far as I know there the fix was not applied to GRASS 7.

I would like to suggest the following patch for r.sun/main.c. Since this
is my first patch for GRASS, apologies if I'm doing it worng.

--- main.c (revision 67790)
+++ main.c (working copy)
@@ -1766,7 +1766,7 @@
          * "local clock time". */
         dayRad = 2. * M_PI * day / 365.25;
         locTimeOffset =
- -0.128 * sin(dayRad - 0.04887) - 0.165 * sin(2 * dayRad +
+ +0.128 * sin(dayRad - 0.04887) + 0.165 * sin(2 * dayRad +
                                                          0.34383);

         /* Time offset due to timezone as input by user */

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2941&gt;
GRASS GIS <https://grass.osgeo.org>

#2941: r.sun: wrong sign in equation of time
--------------------------+-------------------------
  Reporter: tomhuld | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.4
Component: Default | Version: unspecified
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Description changed by neteler:

Old description:

Bug report ticket #2876 by fabriziosossan reported a problem with the
equation of time in r.sun, whereby the calculation of the solar time from
the clock (civil) time is wrong. The problem was fixed with a patch for
GRASS 6, but as far as I know there the fix was not applied to GRASS 7.

I would like to suggest the following patch for r.sun/main.c. Since this
is my first patch for GRASS, apologies if I'm doing it worng.

--- main.c (revision 67790)
+++ main.c (working copy)
@@ -1766,7 +1766,7 @@
         * "local clock time". */
        dayRad = 2. * M_PI * day / 365.25;
        locTimeOffset =
- -0.128 * sin(dayRad - 0.04887) - 0.165 * sin(2 * dayRad +
+ +0.128 * sin(dayRad - 0.04887) + 0.165 * sin(2 * dayRad +
                                                         0.34383);

        /* Time offset due to timezone as input by user */

New description:

Bug report ticket #2876 by fabriziosossan reported a problem with the
equation of time in r.sun, whereby the calculation of the solar time from
the clock (civil) time is wrong. The problem was fixed with a patch for
GRASS 6, but as far as I know there the fix was not applied to GRASS 7.

I would like to suggest the following patch for r.sun/main.c. Since this
is my first patch for GRASS, apologies if I'm doing it worng.

{{{
--- main.c (revision 67790)
+++ main.c (working copy)
@@ -1766,7 +1766,7 @@
          * "local clock time". */
         dayRad = 2. * M_PI * day / 365.25;
         locTimeOffset =
- -0.128 * sin(dayRad - 0.04887) - 0.165 * sin(2 * dayRad +
+ +0.128 * sin(dayRad - 0.04887) + 0.165 * sin(2 * dayRad +
                                                          0.34383);

         /* Time offset due to timezone as input by user */

}}}

--

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2941#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#2941: r.sun: wrong sign in equation of time
--------------------------+-------------------------
  Reporter: tomhuld | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.4
Component: Raster | Version: unspecified
Resolution: | Keywords: r.sun
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by neteler):

* keywords: => r.sun
* component: Default => Raster

Comment:

Replying to [ticket:2941 tomhuld]:
> Bug report ticket #2876 by fabriziosossan reported a problem with the
equation of time in r.sun, whereby the calculation of the solar time from
the clock (civil) time is wrong. The problem was fixed with a patch for
GRASS 6,

So far the proposed patch has not been applied. Should it be? From the
discussion in ticket #2876 it is not clear to me.

> but as far as I know there the fix was not applied to GRASS 7.
>
> I would like to suggest the following patch for r.sun/main.c. Since this
is my first patch for GRASS, apologies if I'm doing it worng.

Ideally please submit the diff as an attachment by (in this case) running

{{{
# from main source code directory
svn diff raster/r.sun/ > r_sun.diff
}}}

(For now, I have reformatted your comment here by protecting it with curly
braces.)

Should your change be submitted in addition to the patch proposed in
ticket #2876 or exclusively your change?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2941#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#2941: r.sun: wrong sign in equation of time
--------------------------+---------------------------------
  Reporter: tomhuld | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.4
Component: Raster | Version: svn-releasebranch70
Resolution: fixed | Keywords: r.sun
       CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------
Changes (by neteler):

* status: new => closed
* version: unspecified => svn-releasebranch70
* resolution: => fixed

Comment:

Thanks for the patch, applied in r68254 (relbranch70) and r68255 (trunk).

Compare also the equivalent alternative GRASS GIS 7 fix suggested in #2876
(commented on in cited email in ​https://lists.osgeo.org/pipermail/grass-
dev/2016-April/079789.html).

Closing.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2941#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>