[GRASS-dev] granularity function

Hi devs, Soeren

I'm looking for a function that return the number of minutes, days,
months, years according the granularity, for example "2 months" should
return 60 days and "1 years" could return 12 months or 365 days.
does it exist a function like that or could I add it to
lib/python/temporal/temporal_granularity.py ?

--
ciao
Luca

www.lucadelu.org

Hi Luca,

2017-05-17 9:36 GMT+02:00 Luca Delucchi <lucadeluge@gmail.com>:

Hi devs, Soeren

I'm looking for a function that return the number of minutes, days,
months, years according the granularity, for example "2 months" should
return 60 days and "1 years" could return 12 months or 365 days.
does it exist a function like that or could I add it to
lib/python/temporal/temporal_granularity.py ?

I am not sure if i understand your approach correctly.

IMHO you would like to return the calendar hierarchy of a specific granularity?
For example, if the granularity of a STDS is calculated to be 2 month,
you would like to return 60 days?
This may not be possible, since the number of days in a month vary for
each month,
as well as the number of days in a year. Hence the result of a
granularity computation
can not be splittet to a smaller calendar hierarchy, since the term
month and year is abstract and not related to a specific year (leap or
not) or a specific month (28 - 31 day range).

Does this answer your question?

Ciao
Sören

--
ciao
Luca

www.lucadelu.org
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

On 17 May 2017 at 10:08, Sören Gebbert <soerengebbert@googlemail.com> wrote:

Hi Luca,

Hi Soeren,

2017-05-17 9:36 GMT+02:00 Luca Delucchi <lucadeluge@gmail.com>:

Hi devs, Soeren

I'm looking for a function that return the number of minutes, days,
months, years according the granularity, for example "2 months" should
return 60 days and "1 years" could return 12 months or 365 days.
does it exist a function like that or could I add it to
lib/python/temporal/temporal_granularity.py ?

I am not sure if i understand your approach correctly.

IMHO you would like to return the calendar hierarchy of a specific granularity?
For example, if the granularity of a STDS is calculated to be 2 month,
you would like to return 60 days?
This may not be possible, since the number of days in a month vary for
each month,
as well as the number of days in a year. Hence the result of a
granularity computation
can not be splittet to a smaller calendar hierarchy, since the term
month and year is abstract and not related to a specific year (leap or
not) or a specific month (28 - 31 day range).

Does this answer your question?

yes and no :slight_smile:

you are right that the term month and year is abstract, but we have
mean values (30 for month and 365 for year) that are commonly
recognized.

Often colleagues required the mean temperature value for the six
months before an event, so how to calculate this?

Ciao
Sören

--
ciao
Luca

www.lucadelu.org

Hi Luca,

2017-05-17 10:51 GMT+02:00 Luca Delucchi <lucadeluge@gmail.com>:

On 17 May 2017 at 10:08, Sören Gebbert <soerengebbert@googlemail.com> wrote:

Hi Luca,

Hi Soeren,

2017-05-17 9:36 GMT+02:00 Luca Delucchi <lucadeluge@gmail.com>:

Hi devs, Soeren

I'm looking for a function that return the number of minutes, days,
months, years according the granularity, for example "2 months" should
return 60 days and "1 years" could return 12 months or 365 days.
does it exist a function like that or could I add it to
lib/python/temporal/temporal_granularity.py ?

I am not sure if i understand your approach correctly.

IMHO you would like to return the calendar hierarchy of a specific granularity?
For example, if the granularity of a STDS is calculated to be 2 month,
you would like to return 60 days?
This may not be possible, since the number of days in a month vary for
each month,
as well as the number of days in a year. Hence the result of a
granularity computation
can not be splittet to a smaller calendar hierarchy, since the term
month and year is abstract and not related to a specific year (leap or
not) or a specific month (28 - 31 day range).

Does this answer your question?

yes and no :slight_smile:

you are right that the term month and year is abstract, but we have
mean values (30 for month and 365 for year) that are commonly
recognized.

Often colleagues required the mean temperature value for the six
months before an event, so how to calculate this?

In case of mean values i would prefer the calculated mean of the
Gregorian calendar that is the base of the temporal framework:

1 year = 365.2425 days
1 month = 30.436875 days
6 months = 182.62125
...

Ciao
Sören

Ciao
Sören

--
ciao
Luca

www.lucadelu.org

On 17 May 2017 at 11:03, Sören Gebbert <soerengebbert@googlemail.com> wrote:

Hi Luca,

Hi,

In case of mean values i would prefer the calculated mean of the
Gregorian calendar that is the base of the temporal framework:

1 year = 365.2425 days
1 month = 30.436875 days
6 months = 182.62125
...

ok, I like this, do you think a function like the one I described
before could be useful to add to temporal framework or it is better to
add it at module level?

Ciao
Sören

--
ciao
Luca

www.lucadelu.org

Hi Luca,

2017-05-17 11:11 GMT+02:00 Luca Delucchi <lucadeluge@gmail.com>:

On 17 May 2017 at 11:03, Sören Gebbert <soerengebbert@googlemail.com> wrote:

Hi Luca,

Hi,

In case of mean values i would prefer the calculated mean of the
Gregorian calendar that is the base of the temporal framework:

1 year = 365.2425 days
1 month = 30.436875 days
6 months = 182.62125
...

ok, I like this, do you think a function like the one I described
before could be useful to add to temporal framework or it is better to
add it at module level?

I think a function that converts the computed granularity in a
different "average" calendar hierarchy is a nice addition to the
framework. Like a function in which you put the computed granularity
and the desired calendar hierarchy as arguments:

def gran_to_gran(from_gran="6 months", to_gran="days"):
    """Converts the computed granularity of a STDS to a smaller
granularity based on the Gregorian calendar hierarchy that 1 year
equals 12 months or 365.2425 days or 24 * 365.2425 hours or 86400 *
365.2425 seconds."""
    .... computation ...
    return 182.62125

Maybe for smaller hierarchies than day the leap second my be of
consideration to compute the average number of hours, minutes and
seconds ... .

Ciao
Sören

Ciao
Sören

--
ciao
Luca

www.lucadelu.org

On 17 May 2017 at 11:27, Sören Gebbert <soerengebbert@googlemail.com> wrote:

Hi Luca,

2017-05-17 11:11 GMT+02:00 Luca Delucchi <lucadeluge@gmail.com>:

On 17 May 2017 at 11:03, Sören Gebbert <soerengebbert@googlemail.com> wrote:

Hi Luca,

Hi,

In case of mean values i would prefer the calculated mean of the
Gregorian calendar that is the base of the temporal framework:

1 year = 365.2425 days
1 month = 30.436875 days
6 months = 182.62125
...

ok, I like this, do you think a function like the one I described
before could be useful to add to temporal framework or it is better to
add it at module level?

I think a function that converts the computed granularity in a
different "average" calendar hierarchy is a nice addition to the
framework. Like a function in which you put the computed granularity
and the desired calendar hierarchy as arguments:

def gran_to_gran(from_gran="6 months", to_gran="days"):
    """Converts the computed granularity of a STDS to a smaller
granularity based on the Gregorian calendar hierarchy that 1 year
equals 12 months or 365.2425 days or 24 * 365.2425 hours or 86400 *
365.2425 seconds."""
    .... computation ...
    return 182.62125

done in r71106.

Maybe for smaller hierarchies than day the leap second my be of
consideration to compute the average number of hours, minutes and
seconds ... .

this is still to investigate, I put a todo in the function's code

Ciao
Sören

--
ciao
Luca

www.lucadelu.org