Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMESTAMP/DATE FORMAT ERROR #6

Open
LKPatel1 opened this issue Sep 5, 2023 · 2 comments
Open

TIMESTAMP/DATE FORMAT ERROR #6

LKPatel1 opened this issue Sep 5, 2023 · 2 comments

Comments

@LKPatel1
Copy link

LKPatel1 commented Sep 5, 2023

Greetings,
Im testing this code, and have treid maintaining the csv just as in the example folder.
My time stamp is in: Day/Month/Year format.
When I run

output_matilda = matilda_simulation(df, output=working_directory,
                                    sim_start='01-01-2003', sim_end='31-12-2022',
                                    freq="D",  # Temporal resolution ("D", "M" or "Y")
                                    lat=76,  # Latitude
                                    area_cat=20.5,  # Catchment area
                                    area_glac=10.5,  # Glaciated area in the catchment
                                    ele_dat=20,  # Reference altitude of the data (e.g. AWS altitude)
                                    ele_glac=350,  # Mean altitude of glaciated area
                                    ele_cat=500,  # Mean catchment elevation

                                    # Optional:
                                    # 1. specify model parameters, e.g.
                                    PCORR=1.5,
                                    # For a list of model parameters and default values check the Parameters file

                                    # 2. Add glacier profile (see Readme) to account for glacier change:
                                    glacier_profile= glacier_profile,
                                    elev_rescaling=True,

                                    # 3. Include interactive plots:
                                    plot_type='all'	# If you receive errors relating to plotly either try a different plotly version or change plot_type to "print"
                                    )

I get the following error

ValueError: time data "13-01-2003" doesn't match format "%m-%d-%Y", at position 12. You might want to try:
    - passing `format` if your strings have a consistent format;
    - passing `format='ISO8601'` if your strings are all ISO8601 but not necessarily in exactly the same format;
    - passing `format='mixed'`, and the format will be inferred for each element individually. You might want to use `dayfirst` alongside this.
    - ```
@LKPatel1
Copy link
Author

LKPatel1 commented Sep 5, 2023

This is the error
###############

/tmp/ipykernel_3626/2106608888.py in <module>
----> 1 output_matilda = matilda_simulation(df, output=working_directory,
      2                                     sim_start='01-01-2003', sim_end='31-12-2022',
      3                                     freq="D",  # Temporal resolution ("D", "M" or "Y")
      4                                     lat=76,  # Latitude
      5                                     area_cat=20.5,  # Catchment area

~/.local/lib/python3.10/site-packages/matilda/core.py in matilda_simulation(input_df, obs, glacier_profile, output, warn, set_up_start, set_up_end, sim_start, sim_end, freq, lat, soi, area_cat, area_glac, ele_dat, ele_glac, ele_cat, plots, plot_type, hydro_year, elev_rescaling, pfilter, drop_surplus, parameter_set, lr_temp, lr_prec, TT_snow, TT_diff, CFMAX_ice, CFMAX_rel, BETA, CET, FC, K0, K1, K2, LP, MAXBAS, PERC, UZL, PCORR, SFCF, CWH, AG, RFS)
   2054         # Downscaling of data if necessary and the MATILDA simulation
   2055         if glacier_profile is not None:
-> 2056             output_MATILDA = matilda_submodules(df_preproc, parameter, glacier_profile=glacier_profile,
   2057                                                 elev_rescaling=elev_rescaling, drop_surplus=drop_surplus)
   2058         else:

~/.local/lib/python3.10/site-packages/matilda/core.py in matilda_submodules(df_preproc, parameter, obs, glacier_profile, elev_rescaling, drop_surplus)
   1260             if glacier_profile is not None:
   1261                 lookup_table = create_lookup_table(glacier_profile, parameter)
-> 1262                 output_DDM, glacier_change, input_df_catchment = updated_glacier_melt(df_preproc, lookup_table,
   1263                                                                                       glacier_profile, parameter,
   1264                                                                                       drop_surplus=drop_surplus)

~/.local/lib/python3.10/site-packages/matilda/core.py in updated_glacier_melt(data, lookup_table, glacier_profile, parameter, drop_surplus)
    658 
    659     # determine hydrological years
--> 660     data["water_year"] = np.where((data.index.month) >= parameter.hydro_year, data.index.year + 1, data.index.year)
    661 
    662     # initial glacier mass from the glacier profile in mm w.e. (relative to the whole catchment)

AttributeError: 'RangeIndex' object has no attribute 'month'

@geoalxx
Copy link
Collaborator

geoalxx commented Sep 8, 2023

Please try again using the following date format. That should fix the error:
sim_start='2000-01-01', sim_end='2099-12-31'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants