<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style id="bidiui-paragraph-margins" type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body bidimailui-detected-decoding-type="UTF-8"
    bidimailui-charset-is-forced="true" style="direction: ltr;"
    text="#933131" bgcolor="#FFFFFF">
    <p><font size="4">Hi Ivan:</font></p>
    <p><font size="4"><br>
      </font></p>
    <div class="moz-cite-prefix">On 29/12/2023 20:34, Ivan Marchesini
      via grass-user wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:3daa1189-18b5-40a7-8d69-671837776f2f@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi veronica<br>
      </p>
      <blockquote type="cite"
cite="mid:CAAMki4EmFest3Czhp+AUHN17Kw-QXUMPftUDQUkHnWGGuykHDQ@mail.gmail.com">
        <div dir="ltr">
          <div><br>
          </div>
          <div>I see what you did with creating the days time series. In
            that way you acknowledge irregular gaps, right? </div>
        </div>
      </blockquote>
      yes this is the reason<br>
      <blockquote type="cite"
cite="mid:CAAMki4EmFest3Czhp+AUHN17Kw-QXUMPftUDQUkHnWGGuykHDQ@mail.gmail.com">
        <div dir="ltr">
          <div><br>
          </div>
          <div>However, why do you multiply by days strds? From my
            understanding, detrending by subtracting the results of a
            model obbeys this rule: value(t) = observed(t) -
            predicted(t). Then, this
            mystrds-(regression_offset+regression_slope*days) should be
            mystrds-(regression_offset+regression_slope*mystrds).</div>
        </div>
      </blockquote>
      <p>hmm <br>
      </p>
      <p>may be I'm wrong but I used r.regression.series to assess a
        relationship between mystrds values and time (days)<br>
      </p>
      <p>As a consequence the offset and slope maps I obtain are b and a
        in the following linear equation</p>
      <p>y=ax+b</p>
      <p>i.e.<br>
      </p>
      <p>predicted_mystrds=slope*days+offset</p>
      <p>This is why I suppose that for detrending I need to do:<br>
      </p>
      <p>mystrds-(predicted_mystrds)</p>
      <p>i.e.<br>
      </p>
      <p>mystrds-(slope*days+offset)</p>
      <p><br>
      </p>
    </blockquote>
    <p><br>
    </p>
    <p>I'm not sure about your procedure of regressing days from start
      of the time series vs the time series. But I would point out: </p>
    <p>The "elephant in the room" for any time series analysis is
      temporal autocorrelation.  If you have some seasonal variation in
      your data, then I don't think that such a regression could work.
      You mentioned data from Nov-Feb over several years, so I assume
      there is some seasonal effect going on?  Normally you have to
      first decompose the time series to remove the seasonal variation,
      and then examine the trend.</p>
    <p><br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:3daa1189-18b5-40a7-8d69-671837776f2f@gmail.com">
      <p> </p>
      <p>I'm I wrong?</p>
      <p>thank you</p>
      <p>Ivan<br>
      </p>
      <p><br>
      </p>
      <p><br>
      </p>
      <blockquote type="cite"
cite="mid:CAAMki4EmFest3Czhp+AUHN17Kw-QXUMPftUDQUkHnWGGuykHDQ@mail.gmail.com">
        <div dir="ltr">
          <div><br>
          </div>
          <div>Best,</div>
          <div>Vero</div>
        </div>
        <br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">El jue, 28 dic 2023 a las
            8:14, Ivan Marchesini (<<a
              href="mailto:ivan.marchesini@gmail.com"
              moz-do-not-send="true" class="moz-txt-link-freetext">ivan.marchesini@gmail.com</a>>)
            escribió:<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>
              <p>Dear Veronica</p>
              <p>I think I found a simple solution using temporal raster
                modules. Here is an example:</p>
              <p>#evaluating info of the strds<br>
                eval `<a href="http://t.info" target="_blank"
                  moz-do-not-send="true">t.info</a> mystrds -g`</p>
              <p>#getting the starting day (of the year, 0-365) of my
                strds<br>
                startday=$(date -d "$start_time" "+%j")<br>
              </p>
              <p>#Creating a new strds where each pixel has the value of
                the count of the days starting from the start_day of my
                strds (the start day in my dataset is in 2016)<br>
                t.rast.mapcalc inputs=mystrds
                expression="(start_year()-2016)*365-${startday}
                +start_doy()" output=days basename=days nprocs=xxx --o<br>
              </p>
              <p>#fitting the trend equation<br>
                r.regression.series xseries="`t.rast.list in=days
                columns=name sep=, format=line`" yseries="` t.rast.list
                in=mystrds columns=name sep=, format=line`" 
                out=regression_offset,regression_slope,regression_rsq,regression_t
                meth=offset,slope,rsq,t<br>
              </p>
              <p>#detrending<br>
                t.rast.mapcalc input=mystrds,days
                expression="mystrds_detrend
                = mystrds-(regression_offset+regression_slope*days)"
                output=mystrds_detrend basename=mystrds_detrend
                nprocs=xxx method=start --o<br>
              </p>
              <p><br>
              </p>
              <p>Best</p>
              <p>Ivan<br>
              </p>
              <p><br>
              </p>
              <p><br>
              </p>
              <p><br>
              </p>
              <div>On 23/12/23 14:53, Ivan Marchesini wrote:<br>
              </div>
              <blockquote type="cite">
                <p>Hi Veronica</p>
                <p>Thank you. It goes in the direction of my idea evn
                  if  my problem is exactly trying to take into account
                  the correct gaps between that data <br>
                </p>
                <p>I have another idea.</p>
                <p>if it works I will come back here to explain how I
                  did</p>
                <p>thank you again</p>
                <p>Ivan<br>
                </p>
                <p><br>
                </p>
                <div>On 22/12/23 13:45, Veronica Andreo wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">Hello Ivan, 
                    <div><br>
                    </div>
                    <div>AFAIU you could use the slope and offset maps
                      from t.rast.series within t.rast.algebra to
                      detrend the values of the maps within the strds,
                      something like "detrended_strds = trend_strds -
                      (trend_strds*map(slope) + map(offset))". Others
                      suggest, to detrend by subtracting the previous
                      value, i.e. that would imply using the temporal
                      algebra with the temporal index, something like
                      "detrended_strds = trend_strds[1] -
                      trend_strds[0]". </div>
                    <div><br>
                    </div>
                    <div>I haven't tested any of these, just a couple of
                      ideas ;-) However, I do not know how this might
                      interact with seasonality within data, or
                      irregular gaps. </div>
                    <div><br>
                    </div>
                    <div>hth somehow</div>
                    <div>Vero</div>
                  </div>
                  <br>
                  <div class="gmail_quote">
                    <div dir="ltr" class="gmail_attr">El vie, 22 dic
                      2023 a las 5:10, Ivan Marchesini via grass-user
                      (<<a href="mailto:grass-user@lists.osgeo.org"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">grass-user@lists.osgeo.org</a>>)
                      escribió:<br>
                    </div>
                    <blockquote class="gmail_quote"
style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear
                      colleagues<br>
                      <br>
                      I would like to the advantage of the t.* modules
                      for detrending a strd.<br>
                      <br>
                      In the strd I have earth observation data
                      irregularly sampled (2 or 3 <br>
                      times per month), in the period November-February,
                      for 7 years. They are <br>
                      not equally spaced (i.e gaps have different
                      duration)<br>
                      <br>
                      A simple t.rast.series analysis
                      (opion=slope,offset) highlights that <br>
                      probably there is a descending trend when
                      considering the maps ordered <br>
                      by id.<br>
                      <br>
                      I would like to fit a proper time depending
                      fitting curve for each pixel <br>
                      and then subtract the function from the real data.<br>
                      <br>
                      any hints on how I can do this task exploiting the
                      GRASS GIS modules or <br>
                      some simple bash/python scripting?<br>
                      <br>
                      thank you<br>
                      <br>
                      Ivan<br>
                      <br>
                      <br>
                      <br>
                      <br>
                      _______________________________________________<br>
                      grass-user mailing list<br>
                      <a href="mailto:grass-user@lists.osgeo.org"
                        target="_blank" moz-do-not-send="true"
                        class="moz-txt-link-freetext">grass-user@lists.osgeo.org</a><br>
                      <a
href="https://lists.osgeo.org/mailman/listinfo/grass-user"
                        rel="noreferrer" target="_blank"
                        moz-do-not-send="true"
                        class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
                    </blockquote>
                  </div>
                </blockquote>
              </blockquote>
            </div>
          </blockquote>
        </div>
      </blockquote>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
  </body>
</html>