Skip to content

Commit f69970b

Browse files
committed
Fix line lenghts
1 parent 6032744 commit f69970b

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

  • esmvaltool/cmorizers/data

‎esmvaltool/cmorizers/data/downloaders/datasets/iap.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def download_dataset(config, dataset, dataset_info, start_date, end_date,
4747
downloader.download_file(
4848
"http://www.ocean.iap.ac.cn/ftp/cheng/"
4949
"IAPv4.2_IAP_Temperature_gridded_1month_netcdf/Monthly/"
50-
f"IAPv4_Temp_monthly_1_6000m_year_{loop_date.year}_month_{loop_date.month:02d}.nc",
50+
f"IAPv4_Temp_monthly_1_6000m_year_{loop_date.year}"
51+
f"_month_{loop_date.month:02d}.nc",
5152
wget_options=[])
5253
loop_date += relativedelta.relativedelta(months=1)

‎esmvaltool/cmorizers/data/formatters/datasets/iap.py‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
Tier 2: other freely-available dataset.
55
66
Source
7-
IAPv4.2: http://www.ocean.iap.ac.cn/ftp/cheng/IAPv4.2_IAP_Temperature_gridded_1month_netcdf/Monthly/
7+
IAPv4.2: "http://www.ocean.iap.ac.cn/ftp/cheng/"
8+
"IAPv4.2_IAP_Temperature_gridded_1month_netcdf/Monthly/"
89
910
Last access: 20250220
1011
@@ -68,7 +69,10 @@ def collect_files(in_dir, var, cfg, start_date, end_date):
6869
loop_date = start_date
6970

7071
while loop_date <= end_date:
71-
fname = f"IAPv4_Temp_monthly_1_6000m_year_{loop_date.year}_month_{loop_date.month:02d}.nc"
72+
fname = (
73+
f"IAPv4_Temp_monthly_1_6000m_year_{loop_date.year}"
74+
f"_month_{loop_date.month:02d}.nc"
75+
)
7276
in_file = os.path.join(in_dir, fname)
7377
file_list.append(in_file)
7478
loop_date += relativedelta.relativedelta(months=1)
@@ -79,7 +83,7 @@ def collect_files(in_dir, var, cfg, start_date, end_date):
7983
def process_data(cube, reference_year):
8084
# Convert temperature from Celsius to Kelvin and add time dimension
8185
temperature_data = cube.data + 273.15
82-
temperature_data = np.expand_dims(temperature_data, axis=0) # Add time dimension
86+
temperature_data = np.expand_dims(temperature_data, axis=0)
8387
temperature_data = np.moveaxis(
8488
temperature_data, (0, 1, 2, 3), (0, 2, 3, 1)
8589
) # Reorder axes
@@ -96,11 +100,15 @@ def process_data(cube, reference_year):
96100
time_coord = iris.coords.DimCoord(
97101
time_points,
98102
standard_name="time",
99-
units=f"days since {reference_date.year}-{reference_date.month}-{reference_date.day}",
103+
units=(
104+
f"days since {reference_date.year}-"
105+
f"{reference_date.month}-{reference_date.day}"
106+
),
100107
)
101108

102109
# Remove old date attributes
103-
for key in ["StartDay", "StartMonth", "StartYear", "EndDay", "EndMonth", "EndYear"]:
110+
for key in ["StartDay", "StartMonth", "StartYear",
111+
"EndDay", "EndMonth", "EndYear"]:
104112
del cube.attributes[key]
105113

106114
# Get existing coordinates and rename 'standard depth' to 'depth'
@@ -147,13 +155,16 @@ def extract_variable(in_files, out_dir, attrs, raw_info, cmor_table):
147155

148156
# derive ocean surface
149157
if "srf_var" in raw_info:
150-
var_info = cmor_table.get_variable(raw_info["mip"], raw_info["srf_var"])
158+
var_info = cmor_table.get_variable(
159+
raw_info["mip"], raw_info["srf_var"]
160+
)
151161
logger.info("Extract surface OBS for %s", raw_info["srf_var"])
152162
level_constraint = iris.Constraint(cube.var_name, depth=1)
153163
cube_os = cube.extract(level_constraint)
154164
fix_var_metadata(cube_os, var_info)
155165
save_variable(
156-
cube_os, raw_info["srf_var"], out_dir, attrs, unlimited_dimensions=["time"]
166+
cube_os, raw_info["srf_var"], out_dir, attrs,
167+
unlimited_dimensions=["time"]
157168
)
158169

159170

0 commit comments

Comments
 (0)