File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -560,7 +560,7 @@ def from_netcdf(self, file_list):
560560 self ._n_data_vars = n_data_vars
561561 self ._n_time_steps = n_time_steps
562562
563- def to_netcdf (self , filename ):
563+ def to_netcdf (self , filename , filepath = "." ):
564564 """
565565 Save the mrCoSTS fit to file in netcdf format.
566566
@@ -569,10 +569,14 @@ def to_netcdf(self, filename):
569569
570570 :param filename: Common name shared by each file.
571571 :type filename: str
572+ :param filepath: Path to save the results. Default is the current
573+ directory.
574+ :type filename: str
575+
572576 """
573577 for c in self ._costs_array :
574578 c .to_xarray ().to_netcdf (
575- "." .join (
579+ filepath .join (
576580 (
577581 filename ,
578582 f"window={ c .window_length :} " ,
Original file line number Diff line number Diff line change @@ -292,8 +292,7 @@ def test_netcdf(tmp_path):
292292 netcdf format and back to mrCOSTS.
293293 """
294294 # Move the I/O tests to the temporary test directory.
295- os .chdir (tmp_path )
296- mrc .to_netcdf ("tests" )
295+ mrc .to_netcdf ("tests" , filepath = tmp_path )
297296 file_list = glob .glob ("*tests*.nc" )
298297 mrc_from_file = mrCOSTS ()
299298 mrc_from_file .from_netcdf (file_list )
You can’t perform that action at this time.
0 commit comments