1- from schimpy .model_time import read_th , get_headers
1+ from schimpy .model_time import read_th
22import pandas as pd
33import os
44
@@ -19,15 +19,20 @@ def calc_net_source_sink(
1919 By default it will look for vsource.th and vsink.th - the default source/sink inputs for SCHISM.
2020 """
2121
22- vsrc = read_th (vsource_file , time_basis = time_basis , elapsed_unit = elapsed_unit )
23- vsink = read_th (vsink_file , time_basis = time_basis , elapsed_unit = elapsed_unit )
22+ vsrc = read_th (
23+ vsource_file ,
24+ time_basis = time_basis ,
25+ elapsed_unit = elapsed_unit ,
26+ head = vsource_head ,
27+ )
28+ vsink = read_th (
29+ vsink_file , time_basis = time_basis , elapsed_unit = elapsed_unit , head = vsink_head
30+ )
2431
2532 # subset by the search_term (eg: a region of source/sink terms)
2633 if search_term is not None :
27- src_head = get_headers (vsource_head )
28- vsrc = vsrc .loc [:, [search_term in x for x in src_head ]]
29- sink_head = get_headers (vsink_head )
30- vsink = vsink .loc [:, [search_term in x for x in sink_head ]]
34+ vsrc = vsrc .loc [:, [search_term in x for x in vsrc .columns ]]
35+ vsink = vsink .loc [:, [search_term in x for x in vsink .columns ]]
3136
3237 # clip to time constraint
3338 if start_date is None :
@@ -60,16 +65,9 @@ def read_flux(
6065 Optionally subset by start_date and end_date.
6166 """
6267
63- flux_df = read_th (flux , time_basis = time_basis , elapsed_unit = elapsed_unit )
64-
65- if flux_head is not None :
66- # Assign headers
67- headers = get_headers (flux_head )
68- if len (headers ) != len (flux_df .columns ):
69- raise ValueError (
70- f"{ os .path .basename (flux )} has { len (flux_df .columns )} columns and the header calls for { len (headers )} !"
71- )
72- flux_df .columns = headers
68+ flux_df = read_th (
69+ flux , time_basis = time_basis , elapsed_unit = elapsed_unit , head = flux_head
70+ )
7371
7472 # Clip to time constraint
7573 if start_date is None :
0 commit comments