Skip to content

Commit

Permalink
Addition of a fixed time zone for timeslices in subannual README
Browse files Browse the repository at this point in the history
  • Loading branch information
erikfilias committed Jul 9, 2020
1 parent 084a338 commit ca32b8f
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions nomenclature/definitions/subannual/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,29 @@ Our convention makes reference to the following agreements:

- Standard datetime format : **UTC**
> The UTC datetime format is adopted to consider the following levels: day, hour, minute, and second if it is necessary (without considering time zones).
> For example: `2020-01-01, 2020-01-02, ...` or `2020-01-01T13:00, ...`
> For example: `2020-01-01, 2020-01-02, ...` or `2020-01-01T13:00:00+01:00, ...`
> Thus, `2020-01-01T13:00:00+01:00` is in the format `"%Y-%m-%dT%H:%M:%S%z"` that is composed by tokens. Each token represents a different part of the date-time, like day, month, year, etc. More details can be found in [strftime() and strptime() Format Codes](https://docs.python.org/3/library/datetime.html).
For a quick reference, here is what we're using in the code above:

- %Y: Year (4 digits)
- %m: Month
- %d: Day of month
- %H: Hour (24 hour)
- %M: Minutes
- %S: Seconds
- %z: Time zone
> The use of lists of dates and datetimes will be generated by the codes of the next section.
- Hour duration :
> It is understood that `2020-01-01T00:00` represents the duration from midnight until 1 a.m. (or whatever the next data point is in a multi-hour timestep resolution). For example: if we have a timestep equal to 2, the next data point will be 2 a.m.
> It is understood that `2020-01-01T00:00+01:00` represents the duration from midnight until 1 a.m. (or whatever the next data point is in a multi-hour timestep resolution). For example: if we have a timestep equal to 2, the next data point will be 2 a.m.
> The multi-hour timestep resolution is the total responsibility of the modeling team that must transform the data as part of the input/output processing workflow.
- Calendar : **Use of real days**
> For any model with an hourly resolution, it assumes that uses 8760 hours for a common year and 8784 hours for leap years as 2020, 2024, etc.
- Using time zone : **Everything is in the same time zone (Berlin, Vienna, Paris, Madrid, etc.)**
> To emphasize that all-time data must be given in UTC format. And, do not include the special treatment for identifying time zones.
> Even if we use `2020-01-01T13:00:00+01:00` that considers time zone, it is important to take in consideration that always time zone will be equal to `+01:00`.
- Summer/Winter-time in continuous-time format :
> It is the total responsibility of each modelling team that must transform the data as part of the input/output processing workflow because the validate() function of nomenclature will validate how the timestamps are provided but it won't recognize the difference between UTC and local time as well as nor transform data from each other.
Expand All @@ -81,11 +92,9 @@ It refers to clustered hours and not consecutive that generates representatives
> For example, Capacity or Reservoir Level at 2020-01-01T13:00 is the value at 1pm, if subannual is given as 2020-01-01, it is understood as midnight that day, if it's January, it is understood as midnight on the first day of the month.

#### Using the format:

The code snippet (Python) below shows how to get lists of dates and datetimes.
#### List of dates:
The code snippet (Python) below shows how to get lists of dates.

- To get a list of dates:
```python
from datetime import timedelta, date

Expand All @@ -98,29 +107,21 @@ end_dt = date(2016, 1, 11)
for dt in daterange(start_dt, end_dt):
print(dt.strftime("%Y-%m-%d"))
```
<!-- - To get a list of datetimes:

- To get a list of datetimes:

```python
from datetime import timedelta, datetime

def DateTimeRange(datetime1, datetime2):
for n in range(int (((datetime2 - datetime1).days)+1)*24):
yield datetime1 + timedelta(hours=n)

start_dt = datetime(2020, 6, 23)
end_dt = datetime(2020, 6, 30)
start_dt = datetime(2020, 6, 23, tzinfo=timezone(timedelta(seconds=3600)))
end_dt = datetime(2020, 6, 30, tzinfo=timezone(timedelta(seconds=3600)))
for dt in DateTimeRange(start_dt, end_dt):
print(dt.strftime("%Y-%m-%d %H:%M:%S"))
``` -->

The format `"%Y-%m-%d %H:%M:%S"` is composed by tokens. Each token represents a different part of the date-time, like day, month, year, etc. More details can be found in [strftime() and strptime() Format Codes](https://docs.python.org/3/library/datetime.html).
For a quick reference, here is what we're using in the code above:

- %Y: Year (4 digits)
- %m: Month
- %d: Day of month
- %H: Hour (24 hour)
- %M: Minutes
- %S: Seconds
print(dt.strftime("%Y-%m-%d %H:%M:%S%z"))
```

### Other categories

Expand Down

0 comments on commit ca32b8f

Please sign in to comment.