@@ -135,9 +135,7 @@ def open_cbc(
135135
136136 """
137137 grid = StructuredGridWrapper .from_binary_grid_file (grb_path )
138- cbc = _open_cbc_dis (
139- cbc_path , grid , flowja , simulation_start_time , time_unit
140- )
138+ cbc = _open_cbc_dis (cbc_path , grid , flowja , simulation_start_time , time_unit )
141139 return xr .merge ([cbc ])
142140
143141
@@ -267,17 +265,13 @@ def read_cbc_headers(
267265 if header ["imeth" ] == 1 :
268266 # Multiply by -1 because ndim3 is stored as a negative for some
269267 # reason. (ndim3 is the integer size of the third dimension)
270- datasize = (
271- header ["ndim1" ] * header ["ndim2" ] * header ["ndim3" ] * - 1
272- ) * 8
268+ datasize = (header ["ndim1" ] * header ["ndim2" ] * header ["ndim3" ] * - 1 ) * 8
273269 header ["pos" ] = f .tell ()
274270 key = header ["text" ]
275271 headers [key ].append (Imeth1Header (** header ))
276272 elif header ["imeth" ] == 6 :
277273 imeth6_header = read_imeth6_header (f )
278- datasize = imeth6_header ["nlist" ] * (
279- 8 + imeth6_header ["ndat" ] * 8
280- )
274+ datasize = imeth6_header ["nlist" ] * (8 + imeth6_header ["ndat" ] * 8 )
281275 header ["pos" ] = f .tell ()
282276 # key-format:
283277 # "package type"-"optional_package_variable"_"package name"
@@ -287,11 +281,7 @@ def read_cbc_headers(
287281 # npf-key can be present multiple times in cases of saved
288282 # saturation + specific discharge
289283 if header ["text" ].startswith ("data-" ):
290- key = (
291- imeth6_header ["txt2id2" ]
292- + "_"
293- + header ["text" ].replace ("data-" , "" )
294- )
284+ key = imeth6_header ["txt2id2" ] + "_" + header ["text" ].replace ("data-" , "" )
295285 headers [key ].append (Imeth6Header (** header , ** imeth6_header ))
296286 else :
297287 raise ValueError (
@@ -332,9 +322,7 @@ def read_imeth6_header(f: BinaryIO) -> dict[str, Any]:
332322 content ["txt2id2" ] = f .read (16 ).decode ("utf-8" ).strip ().lower ()
333323 ndat = struct .unpack ("i" , f .read (4 ))[0 ]
334324 content ["ndat" ] = ndat
335- content ["auxtxt" ] = [
336- f .read (16 ).decode ("utf-8" ).strip ().lower () for _ in range (ndat - 1 )
337- ]
325+ content ["auxtxt" ] = [f .read (16 ).decode ("utf-8" ).strip ().lower () for _ in range (ndat - 1 )]
338326 content ["nlist" ] = struct .unpack ("i" , f .read (4 ))[0 ]
339327 return content
340328
@@ -345,14 +333,9 @@ def assign_datetime_coords(
345333 time_unit : str | None = "d" ,
346334) -> xr .DataArray :
347335 if "time" not in da .coords :
348- raise ValueError (
349- "cannot convert time column, "
350- "because a time column could not be found"
351- )
336+ raise ValueError ("cannot convert time column, because a time column could not be found" )
352337
353- time = pd .Timestamp (simulation_start_time ) + pd .to_timedelta (
354- da ["time" ], unit = time_unit
355- )
338+ time = pd .Timestamp (simulation_start_time ) + pd .to_timedelta (da ["time" ], unit = time_unit )
356339 return da .assign_coords (time = time )
357340
358341
@@ -411,9 +394,7 @@ def open_imeth6_budgets(
411394 coords = get_coords (grid )
412395 coords ["time" ] = time
413396 name = header_list [0 ].text
414- return xr .DataArray (
415- daskarr , coords , ("time" , "layer" , "y" , "x" ), name = name
416- )
397+ return xr .DataArray (daskarr , coords , ("time" , "layer" , "y" , "x" ), name = name )
417398
418399
419400def read_imeth6_budgets_dense (
@@ -470,9 +451,7 @@ def read_imeth6_budgets_dense(
470451 return out .reshape (shape )
471452
472453
473- def read_imeth6_budgets (
474- cbc_path : Path , count : int , dtype : np .dtype , pos : int
475- ) -> Any :
454+ def read_imeth6_budgets (cbc_path : Path , count : int , dtype : np .dtype , pos : int ) -> Any :
476455 """
477456 Read the data for an imeth==6 budget section for a single timestep.
478457
@@ -549,9 +528,7 @@ def open_imeth1_budgets(
549528 )
550529
551530
552- def cbc_open_imeth1_budgets (
553- cbc_path : Path , header_list : list [Imeth1Header ]
554- ) -> xr .DataArray :
531+ def cbc_open_imeth1_budgets (cbc_path : Path , header_list : list [Imeth1Header ]) -> xr .DataArray :
555532 """
556533 Open the data for an imeth==1 budget section. Data is read lazily per
557534 timestep. The cell data is not spatially labelled.
@@ -625,19 +602,15 @@ def dis_open_face_budgets(
625602 front: xr.DataArray of floats with dims ("time", "layer", "y", "x")
626603 lower: xr.DataArray of floats with dims ("time", "layer", "y", "x")
627604 """
628- right_index , front_index , lower_index = dis_to_right_front_lower_indices (
629- grid
630- )
605+ right_index , front_index , lower_index = dis_to_right_front_lower_indices (grid )
631606 budgets = cbc_open_imeth1_budgets (cbc_path , header_list )
632607 right = dis_extract_face_budgets (budgets , right_index )
633608 front = dis_extract_face_budgets (budgets , front_index )
634609 lower = dis_extract_face_budgets (budgets , lower_index )
635610 return right , front , lower
636611
637612
638- def dis_extract_face_budgets (
639- budgets : xr .DataArray , index : xr .DataArray
640- ) -> xr .DataArray :
613+ def dis_extract_face_budgets (budgets : xr .DataArray , index : xr .DataArray ) -> xr .DataArray :
641614 """
642615 Grab right, front, or lower face flows from the flow-ja-face array.
643616
0 commit comments