pymagicc.core¶
Handling of conversion from datetime to MAGICC’s internal time conventions and back.
Internally, MAGICC effectively operates on a monthly calendar, where each year is comprised of 12 equally sized months. This convention means that we have to be a bit careful when moving back and forth between datetimes and MAGICC’s time conventions. However, we also want Pymagicc to be a little bit flexible and smart about how it handles these conversions. As a result, we must interpret ‘middle of the month’ and ‘start of the month’ rather than strictly defining them. This module defines these interpretations
- pymagicc.magicc_time.convert_to_datetime(decimal_year)[source]¶
Convert a decimal year from MAGICC to a datetime
- Parameters
decimal_year (float) – Time point to convert
- Returns
Datetime representation of MAGICC’s decimal year
- Return type
datetime.datetime
- Raises
ValueError – If we are not confident that the input times follow MAGICC’s internal time conventions (i.e. are not start or middle of the month).
- pymagicc.magicc_time.convert_to_decimal_year(idtime)[source]¶
Convert a datetime to MAGICC’s expected decimal year representation
- Parameters
idtime (
datetime.datetime
) –datetime.datetime
instance to convert to MAGICC’s internal decimal year conventions- Returns
MAGICC’s internal decimal year representation of
idtime
- Return type
float
- Raises
ValueError – If we are not confident about how to convert the input times so that they follow MAGICC’s internal time conventions (i.e. we are not sure if
idtime
is start or middle of the month).