Skip to content

Conversation

@aleaf
Copy link
Contributor

@aleaf aleaf commented Nov 12, 2020

This pull request is intended to allow users to input files to PstFrom.add_parameters that aren't at the root level of the model workspace. It also includes an option to write template files to a subfolder (via a tpl_subfolder argument to PstFrom.__init__()).

This is mostly implemented by refactoring pathing to use pathlib instead of os.path. The following types of pathing situations should work (see the tests in autotest/pst_from_tests.py:TestPstFrom for more details):

            Path('hk0.dat'),  # sim_ws; just file name as Path instance
            'hk1.dat',  # sim_ws; just file name as string
            Path(self.sim_ws, 'hk2.dat'),  # sim_ws; full path as Path instance
            'external/hk3.dat',  # subfolder; relative file path as string
            Path('external/hk4.dat'),  # subfolder; relative path as Path instance
            '../external_files/hk5.dat',  # subfolder up one level

@jtwhite79 @briochh Let me know what you think!

* implemented by refactoring file handling from os.path to use pathlib
* input array or list text files can be in the model workspace a subfolder, or another folder outside of the model workspace
* regardless of the input file location, "org" and "mult" files are kept in a flat structure in their respective folders as before
* the resulting model input files are written to the same relative locations as their original versions
* tpl and pilot point-related files are still written to the root level of the model workspace
* tests include single array files with par_types zone, pilotpoints and grid, an array file list with par_type=zone, and single list files with par_type=constant
…thin the model workspace

fix(pst_from): issue with in_fileabs and in_filepst when par_style != 'multiplier'
…ion cases where there is not 'mlt_file' column in the mult2model_info dataframe

fix(pst_from.write_array_tpl): order of operations in _check_diff
fix(pst_from._par_prep): use predefined org_file path for case with no header
tests(pst_from): add basic test for 'direct' parameterization with datafiles in subfolder; make list testdata one-based
@jtwhite79
Copy link
Collaborator

Thanks @aleaf ! I'm gonna kick tires a little tomorrow on a few active use cases but this looks excellent!

@jtwhite79 jtwhite79 merged commit e202e8e into pypest:develop Nov 17, 2020
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

Successfully merging this pull request may close these issues.

2 participants