gmdsi / GMDSI_notebooks

python-based predictive groundwater modeling workflow examples
GNU General Public License v3.0
48 stars 31 forks source link

Bug with "intro_to_regularization" (or possible human error) #79

Closed DStrom1987 closed 1 year ago

DStrom1987 commented 1 year ago

Hi,

Im receiving the following error when I'm trying to run the intro_to_regularization tutorial. Being somewhat novice to Python I cant really wrap my head around what I should proceed to do? It probably has something to do with dependencies or how i set up anaconda/python? Since it ran just fine on another computer. I tried to change the syntax for the line-terminator as per the last error-message without success.

Any ideas as to what it can be?

David

ins file for heads.csv prepared. ins file for sfr.csv prepared. noptmax:0, npar_adj:1, nnz_obs:24 written pest control file: freyberg_mf6\freyberg.pst could not remove start_datetime 1 pars added from template file .\freyberg6.sfr_perioddata_1.txt.tpl 6 pars added from template file .\freyberg6.wel_stress_period_data_10.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_11.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_12.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_2.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_3.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_4.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_5.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_6.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_7.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_8.txt.tpl 0 pars added from template file .\freyberg6.wel_stress_period_data_9.txt.tpl

TypeError Traceback (most recent call last) Cell In[2], line 15 13 hbd.prep_pest(tmp_d) 14 # convenience function that builds a new control file with pilot point parameters for hk ---> 15 hbd.add_ppoints(tmp_d)

File ~\OneDrive - Sweco AB\Documents\GMDSI_notebooks-main\tutorials\part1_09_regularization..\herebedragons.py:450, in add_ppoints(tmp_d) 448 ###--construct ppoints 449 prefix_dict = {0:["hk"]} --> 450 df_pp = pyemu.pp_utils.setup_pilotpoints_grid(sr=sr, # model spatial reference 451 ibound=ibound, # to which cells to setup ppoints 452 prefix_dict=prefix_dict, #prefix to add to parameter names 453 pp_dir=tmp_d, 454 tpl_dir=tmp_d, 455 every_n_cell=5) # pilot point spacing 456 pp_file_hk = os.path.join(tmp_d,"hkpp.dat") 457 assert os.path.exists(pp_file_hk)

File ~\OneDrive - Sweco AB\Documents\GMDSI_notebooks-main\tutorials\part1_09_regularization....\dependencies\pyemu\utils\pp_utils.py:282, in setup_pilotpoints_grid(ml, sr, ibound, prefix_dict, every_n_cell, ninst, use_ibound_zones, pp_dir, tpl_dir, shapename, pp_filename_dict) 280 tpl_filename = os.path.join(tpl_dir, base_filename + ".tpl") 281 # write the tpl file --> 282 pp_df = pilot_points_to_tpl( 283 pp_df, tpl_filename, name_prefix=prefix, 284 ) 285 pp_df.loc[:, "tpl_filename"] = tpl_filename 286 pp_df.loc[:, "pp_filename"] = pp_filename

File ~\OneDrive - Sweco AB\Documents\GMDSI_notebooks-main\tutorials\part1_09_regularization....\dependencies\pyemu\utils\pp_utils.py:618, in pilot_points_to_tpl(pp_file, tpl_file, name_prefix) 614 pp_df.loc[:, "parnme"] = pp_df.name 615 pp_df.loc[:, "tpl"] = pp_df.parnme.apply( 616 lambda x: "~ {0} ~".format(x) 617 ) --> 618 _write_df_tpl( 619 tpl_file, 620 pp_df.loc[:, ["name", "x", "y", "zone", "tpl"]], 621 sep=" ", 622 index_label="index", 623 header=False, 624 index=False, 625 quotechar=" ", 626 quoting=2, 627 ) 629 return pp_df

File ~\OneDrive - Sweco AB\Documents\GMDSI_notebooks-main\tutorials\part1_09_regularization....\dependencies\pyemu\utils\helpers.py:2296, in _write_df_tpl(filename, df, sep, tpl_marker, headerlines, kwargs) 2294 if headerlines is not None: 2295 _add_headerlines(f, headerlines) -> 2296 df.to_csv(f, sep=sep, mode="a", kwargs)

TypeError: NDFrame.to_csv() got an unexpected keyword argument 'line_terminator'

image image

rhugman commented 1 year ago

Hi @DStrom1987, sorry to hear this.

I suspect it is due to the recent release of Pandas 2.0.

Could you please clone the 'develop' branch of the tutorial notebooks and re-install the 'conda' environment using the updated 'environment.yml' file. Please let me know if that does not work.

Cheers R

DStrom1987 commented 1 year ago

Hi,

I'm not sure. downloaded the .yml again and updated my environment. Now I got a similar message:

image image

I'm planning on getting into GIT soon enough, but for now i re-downloaded the repository and ran the tutorial in the new conda environment after setting up with the new .yml.

From what it seems the .yml was updated "last year". Is this the new one? (see below) image

Any other ideas?

Sincerely David

rhugman commented 1 year ago

Hi @DStrom1987 ,

Unfortunately, you will need to switch to the develop branch of the repo. See red circle in screenshot below. Please try switching branches, then download (or clone) the entire repository and re-install the conda environment.

image

DStrom1987 commented 1 year ago

Ah, my mistake! thanks for clearing that up.

David

DStrom1987 commented 1 year ago

Now it works like a charm. Thanks for all the assistance :)

rhugman commented 1 year ago

Great! :)