Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 13, 2023
1 parent cf26140 commit 3576dde
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 92 deletions.
102 changes: 48 additions & 54 deletions disdrodb/l0/routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,26 +220,24 @@ def run_disdrodb_l0a_station(
):
"""Run the L0A processing of a station calling the disdrodb_l0a_station in the terminal."""
# Define command
cmd = " ".join(
[
"disdrodb_run_l0a_station",
# Station arguments
data_source,
campaign_name,
station_name,
# Processing options
"--force",
str(force),
"--verbose",
str(verbose),
"--debugging_mode",
str(debugging_mode),
"--parallel",
str(parallel),
"--base_dir",
str(base_dir),
]
)
cmd = " ".join([
"disdrodb_run_l0a_station",
# Station arguments
data_source,
campaign_name,
station_name,
# Processing options
"--force",
str(force),
"--verbose",
str(verbose),
"--debugging_mode",
str(debugging_mode),
"--parallel",
str(parallel),
"--base_dir",
str(base_dir),
])
# Execute command
_execute_cmd(cmd)
return None
Expand All @@ -259,26 +257,24 @@ def run_disdrodb_l0b_station(
):
"""Run the L0B processing of a station calling disdrodb_run_l0b_station in the terminal."""
# Define command
cmd = " ".join(
[
"disdrodb_run_l0b_station",
# Station arguments
data_source,
campaign_name,
station_name,
# Processing options
"--force",
str(force),
"--verbose",
str(verbose),
"--debugging_mode",
str(debugging_mode),
"--parallel",
str(parallel),
"--base_dir",
str(base_dir),
]
)
cmd = " ".join([
"disdrodb_run_l0b_station",
# Station arguments
data_source,
campaign_name,
station_name,
# Processing options
"--force",
str(force),
"--verbose",
str(verbose),
"--debugging_mode",
str(debugging_mode),
"--parallel",
str(parallel),
"--base_dir",
str(base_dir),
])
# Execute command
_execute_cmd(cmd)
return None
Expand All @@ -296,20 +292,18 @@ def run_disdrodb_l0b_concat_station(
This function runs the ``disdrodb_run_l0b_concat_station`` script in the terminal.
"""
cmd = " ".join(
[
"disdrodb_run_l0b_concat_station",
data_source,
campaign_name,
station_name,
"--remove_l0b",
str(remove_l0b),
"--verbose",
str(verbose),
"--base_dir",
str(base_dir),
]
)
cmd = " ".join([
"disdrodb_run_l0b_concat_station",
data_source,
campaign_name,
station_name,
"--remove_l0b",
str(remove_l0b),
"--verbose",
str(verbose),
"--base_dir",
str(base_dir),
])
_execute_cmd(cmd)


Expand Down
24 changes: 11 additions & 13 deletions disdrodb/tests/test_l0/test_l0a_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,11 @@ def test_is_not_corrupted():

def test_cast_column_dtypes():
# Create a test dataframe with object columns
df = pd.DataFrame(
{
"time": ["2022-01-01 00:00:00", "2022-01-01 00:05:00", "2022-01-01 00:10:00"],
"station_number": "station_number",
"altitude": "8849",
}
)
df = pd.DataFrame({
"time": ["2022-01-01 00:00:00", "2022-01-01 00:05:00", "2022-01-01 00:10:00"],
"station_number": "station_number",
"altitude": "8849",
})
# Call the function
sensor_name = "OTT_Parsivel"
df_out = cast_column_dtypes(df, sensor_name, verbose=False)
Expand Down Expand Up @@ -552,12 +550,12 @@ def test_read_raw_files():
verbose = False

# Create a test dataframe
df1 = pd.DataFrame(
{"time": pd.date_range(start="2022-01-01", end="2022-01-02", freq="H"), "value": np.random.rand(25)}
)
df2 = pd.DataFrame(
{"time": pd.date_range(start="2022-01-03", end="2022-01-04", freq="H"), "value": np.random.rand(25)}
)
df1 = pd.DataFrame({
"time": pd.date_range(start="2022-01-01", end="2022-01-02", freq="H"), "value": np.random.rand(25)
})
df2 = pd.DataFrame({
"time": pd.date_range(start="2022-01-03", end="2022-01-04", freq="H"), "value": np.random.rand(25)
})
df_list = [df1, df2]

# Mock the process_raw_file function
Expand Down
44 changes: 19 additions & 25 deletions disdrodb/tests/test_l0/test_l0b_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,15 @@ def define_test_dummy_configs():
@pytest.mark.parametrize("create_test_config_files", [define_test_dummy_configs()], indirect=True)
def test_create_l0b_from_l0a(create_test_config_files):
# Create a sample DataFrame
df = pd.DataFrame(
{
"time": pd.date_range("2022-01-01", periods=10, freq="H"),
"raw_drop_concentration": np.random.rand(10),
"raw_drop_average_velocity": np.random.rand(10),
"raw_drop_number": np.random.rand(10),
"latitude": np.random.rand(10),
"longitude": np.random.rand(10),
"altitude": np.random.rand(10),
}
)
df = pd.DataFrame({
"time": pd.date_range("2022-01-01", periods=10, freq="H"),
"raw_drop_concentration": np.random.rand(10),
"raw_drop_average_velocity": np.random.rand(10),
"raw_drop_number": np.random.rand(10),
"latitude": np.random.rand(10),
"longitude": np.random.rand(10),
"altitude": np.random.rand(10),
})
# Create a sample attrs dictionary
attrs = {
"sensor_name": "test",
Expand Down Expand Up @@ -149,13 +147,11 @@ def test_create_l0b_from_l0a(create_test_config_files):

def test_add_dataset_crs_coords():
# Create example dataset
ds = xr.Dataset(
{
"var1": xr.DataArray([1, 2, 3], dims="time"),
"lat": xr.DataArray([0, 1, 2], dims="time"),
"lon": xr.DataArray([0, 1, 2], dims="time"),
}
)
ds = xr.Dataset({
"var1": xr.DataArray([1, 2, 3], dims="time"),
"lat": xr.DataArray([0, 1, 2], dims="time"),
"lon": xr.DataArray([0, 1, 2], dims="time"),
})

# Call the function and check the output
ds_out = add_dataset_crs_coords(ds)
Expand All @@ -181,13 +177,11 @@ def test_set_attrs_dict():

def test__set_coordinate_attributes():
# Create example dataset
ds = xr.Dataset(
{
"var1": xr.DataArray([1, 2, 3], dims="time"),
"lat": xr.DataArray([0, 1, 2], dims="time"),
"lon": xr.DataArray([0, 1, 2], dims="time"),
}
)
ds = xr.Dataset({
"var1": xr.DataArray([1, 2, 3], dims="time"),
"lat": xr.DataArray([0, 1, 2], dims="time"),
"lon": xr.DataArray([0, 1, 2], dims="time"),
})
ds.lat.attrs["units"] = "degrees_north"
ds.lon.attrs["units"] = "degrees_east"

Expand Down

0 comments on commit 3576dde

Please sign in to comment.