Skip to content

Commit

Permalink
return just file
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasia-popova committed Apr 6, 2024
1 parent 1db2ae4 commit b169ab5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions artifacts/artifact_funcs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ function artifact_data(datapath_full, name, datapath_trunc, date0, time_start, t
println(datapath_trunc)
println(name)
println(comms_ctx)
(datafile_truncated, start_id, end_id) =
Regridder.truncate_dataset(date0, time_start, time_end, datafile, datapath_trunc, name, comms_ctx)
return (; datafile_truncated, start_id, end_id)
datafile_truncated = Regridder.truncate_dataset(date0, time_start, time_end, datafile, datapath_trunc, name, comms_ctx)
return datafile_truncated
end
6 changes: 3 additions & 3 deletions experiments/AMIP/coupler_driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ include(joinpath(pkgdir(ClimaCoupler), "artifacts", "artifact_funcs.jl"))
#sic_data_all = joinpath(sic_dataset_path(), "sic.nc")
#co2_data_all = joinpath(co2_dataset_path(), "mauna_loa_co2.nc")
#land_mask_data = joinpath(mask_dataset_path(), "seamask.nc")
sst_data, = artifact_data(sst_dataset_path(), "sst", REGRID_DIR, date0, t_start, t_end, comms_ctx)
sic_data, = artifact_data(sic_dataset_path(), "sic", REGRID_DIR, date0, t_start, t_end, comms_ctx)
co2_data, = artifact_data(co2_dataset_path(), "mauna_loa_co2", REGRID_DIR, date0, t_start, t_end, comms_ctx)
sst_data = artifact_data(sst_dataset_path(), "sst", REGRID_DIR, date0, t_start, t_end, comms_ctx)
sic_data = artifact_data(sic_dataset_path(), "sic", REGRID_DIR, date0, t_start, t_end, comms_ctx)
co2_data = artifact_data(co2_dataset_path(), "mauna_loa_co2", REGRID_DIR, date0, t_start, t_end, comms_ctx)
land_mask_data = artifact_data(mask_dataset_path(), "seamask")

# truncate data sets to needed dates
Expand Down
2 changes: 1 addition & 1 deletion src/Regridder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ function truncate_dataset(
close(ds)
close(truncated_ds)

return (; datafile_truncated, start_id, end_id)
return datafile_truncated
end
end

Expand Down
7 changes: 3 additions & 4 deletions test/regridder_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ end
date0test = ["18690101", "18700101", "19790228", "20220301", "20230101"]
for date in date0test
date0 = DateTime(date, dateformat"yyyymmdd")
(sst_data, start_id, end_id) =
Regridder.truncate_dataset(date0, time_start, time_end, sst_data_all, REGRID_DIR, "test", comms_ctx)
sst_data = Regridder.truncate_dataset(date0, time_start, time_end, sst_data_all, REGRID_DIR, "test", comms_ctx)
nds = NCDataset(sst_data, "r")
new_dates = nds["time"][:]

Expand All @@ -378,8 +377,8 @@ end
end

#tests to make sure the datasets were truncated correctly
@test nds["time"][1] == ds["time"][start_id]
@test last(nds["time"][:]) == ds["time"][end_id]
#@test nds["time"][1] == ds["time"][start_id]
#@test last(nds["time"][:]) == ds["time"][end_id]

close(nds)
end
Expand Down

0 comments on commit b169ab5

Please sign in to comment.