@@ -3600,31 +3600,34 @@ def apply_list_pars():
3600
3600
fmts += " %9G"
3601
3601
np .savetxt (os .path .join (model_ext_path , fname ), df_list .loc [:, names ].values , fmt = fmts )
3602
3602
3603
- def apply_hfb_pars ():
3603
+ def apply_hfb_pars (par_file = 'hfb6_pars.csv' ):
3604
3604
""" a function to apply HFB multiplier parameters. Used to implement
3605
3605
the parameterization constructed by write_hfb_zone_multipliers_template()
3606
3606
3607
- This is to account for the horrible HFB6 format that differs from other BCs making this a special case
3607
+ This is to account for the horrible HFB6 format that differs from other
3608
+ BCs making this a special case
3608
3609
3609
3610
Note
3610
3611
----
3611
3612
requires "hfb_pars.csv"
3612
3613
3613
3614
should be added to the forward_run.py script
3614
3615
"""
3615
- hfb_pars = pd .read_csv ('hfb6_pars.csv' )
3616
+ hfb_pars = pd .read_csv (par_file )
3616
3617
3617
3618
hfb_mults_contents = open (hfb_pars .mlt_file .values [0 ], 'r' ).readlines ()
3618
- skiprows = sum ([1 if i .strip ().startswith ('#' ) else 0 for i in hfb_mults_contents ]) + 1
3619
+ skiprows = sum ([1 if i .strip ().startswith ('#' ) else 0
3620
+ for i in hfb_mults_contents ]) + 1
3619
3621
header = hfb_mults_contents [:skiprows ]
3620
3622
3621
3623
# read in the multipliers
3622
3624
names = ['lay' , 'irow1' ,'icol1' ,'irow2' ,'icol2' , 'hydchr' ]
3623
- hfb_mults = pd .read_csv (hfb_pars .mlt_file .values [0 ], skiprows = skiprows , delim_whitespace = True , names = names ). dropna ()
3624
-
3625
+ hfb_mults = pd .read_csv (hfb_pars .mlt_file .values [0 ], skiprows = skiprows ,
3626
+ delim_whitespace = True , names = names ). dropna ()
3625
3627
3626
3628
# read in the original file
3627
- hfb_org = pd .read_csv (hfb_pars .org_file .values [0 ], skiprows = skiprows , delim_whitespace = True , names = names ).dropna ()
3629
+ hfb_org = pd .read_csv (hfb_pars .org_file .values [0 ], skiprows = skiprows ,
3630
+ delim_whitespace = True , names = names ).dropna ()
3628
3631
3629
3632
# multiply it out
3630
3633
hfb_org .hydchr *= hfb_mults .hydchr
@@ -3633,11 +3636,12 @@ def apply_hfb_pars():
3633
3636
hfb_mults [cn ] = hfb_mults [cn ].astype (np .int )
3634
3637
hfb_org [cn ] = hfb_org [cn ].astype (np .int )
3635
3638
# write the results
3636
- with open (hfb_pars .model_file .values [0 ], 'w' ) as ofp :
3639
+ with open (hfb_pars .model_file .values [0 ], 'w' , newline = '' ) as ofp :
3637
3640
[ofp .write ('{0}\n ' .format (line .strip ())) for line in header ]
3641
+ ofp .flush ()
3642
+ hfb_org [['lay' , 'irow1' , 'icol1' , 'irow2' , 'icol2' , 'hydchr' ]].to_csv (
3643
+ ofp , sep = ' ' , header = None , index = None )
3638
3644
3639
- hfb_org [['lay' , 'irow1' ,'icol1' ,'irow2' ,'icol2' , 'hydchr' ]].to_csv (ofp , sep = ' ' ,
3640
- header = None , index = None )
3641
3645
3642
3646
def write_const_tpl (name , tpl_file , suffix , zn_array = None , shape = None , spatial_reference = None ,
3643
3647
longnames = False ):
0 commit comments