modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
523 stars 314 forks source link

feature: Rename all output files #1818

Open Julien-K opened 1 year ago

Julien-K commented 1 year ago

Dear maintainers,

I'm not sure the following described behaviour is a feature request or a bug, or something I missed in the doc.

I'm working on parametric grids; I have a ModelMuse-generated mf6 project as base model and I want to duplicate it for each case of my study.

Each case-model should be named with a pattern:

Here is a code sample:

import flopy as fp
import numpy as np
import copy
import os

simName = 'myModel'
Orig_sim = './orig'
exeName = 'c:\\local\\WRDAPP\\mf6.4.1\\bin\\mf6.exe'

sim = fp.mf6.MFSimulation.load(simName,exe_name=exeName,verbosity_level=1,sim_ws=Orig_sim)
case_sim = copy.deepcopy(sim) 
case_sim_path = Orig_sim + '\\test_v01'
case_sim_name = simName + '_v01'
case_sim.set_sim_path(case_sim_path)

case_sim.rename_all_packages(case_sim_name)

case_sim.write_simulation()
case_sim.run_simulation()

All input files are correctly named following the given pattern.

myModel_v01.chd
myModel_v01.disv
myModel_v01.disv.grb
myModel_v01.gnc
myModel_v01.hfb
myModel_v01.ic
myModel_v01.ims
myModel_v01.nam
myModel_v01.npf
myModel_v01.ob_gw
myModel_v01.oc
myModel_v01.sto
myModel_v01.tdis

But output file names for packages OC, OBS and IMS (at least) are not modified following the given pattern, I still get:

mfsim.lst
mfsim.nam
myModel.InnerSolution.CSV
myModel.OuterSolution.CSV
myModel.bhd
myModel.ob_gw_out_head.csv
mymodel.lst

I see from the doc that I can alter manually the 'bhd' file (OC package) and the IMS output files, but I didn't find a method for the OBS6 output files.

Is there a clean way to rename all these files?

Regards, Julien

wpbonelli commented 11 months ago

@Julien-K apology for the delay here. Someone else more knowledgeable might jump in here and correct me but I don't think there is a clean way to do this — consistent naming for input and output files (per the given model name) seems like the ideal behavior, so this could even be considered a bug?

ougx commented 11 months ago

This example could be helpful: https://flopy.readthedocs.io/en/3.3.5/_notebooks/tutorial02_mf6_data.html

And mf6obs API: https://flopy.readthedocs.io/en/3.3.5/source/flopy.mf6.modflow.mfutlobs.html

It is possible that multiple obs output files can be used in the same package. Therefore, it is not applicable to use a uniform case name for all the files.

langevin-usgs commented 11 months ago

@Julien-K, for better or worse, we've set up flopy and MODFLOW 6 to use a dedicated folder for each simulation. Since you are changing the folder name for each case is it necessary to change the base file name inside the folder as well? Just trying to fully understand the use case.

Julien-K commented 11 months ago

Hi Christian, that's indeed what I was trying to do: each simulation's name is the folder's name. It works for all files but the output files (lst, bhd and csv files).