Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 5d953c4

Browse files
committed
Merge branch 'main' into issue/209-xrdatarray-b
2 parents 1a069cf + 4fad459 commit 5d953c4

File tree

2 files changed

+438
-0
lines changed

2 files changed

+438
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "0d39c43a-afae-4a54-b1ea-eb48f00f10ae",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"from pathlib import Path"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": 2,
16+
"id": "41dcea91-eaab-4e46-ba83-fada36357067",
17+
"metadata": {},
18+
"outputs": [],
19+
"source": [
20+
"EUMETSAT_PATH = Path(\"/mnt/storage_a/data/ocf/solar_pv_nowcasting/nowcasting_dataset_pipeline/satellite/EUMETSAT/SEVIRI_RSS/native/\")"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": 3,
26+
"id": "3533e596-57c7-4e52-b83d-0da0f2c72ea2",
27+
"metadata": {},
28+
"outputs": [],
29+
"source": [
30+
"def list_directories(path: Path, pattern: str) -> list[Path]:\n",
31+
" return [x for x in path.glob(pattern) if x.is_dir()]"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 4,
37+
"id": "d1db021b-9a19-483b-ad3e-fddcc72b194c",
38+
"metadata": {},
39+
"outputs": [
40+
{
41+
"name": "stdout",
42+
"output_type": "stream",
43+
"text": [
44+
"CPU times: user 10.8 ms, sys: 4.65 ms, total: 15.5 ms\n",
45+
"Wall time: 32.1 ms\n"
46+
]
47+
},
48+
{
49+
"data": {
50+
"text/plain": [
51+
"613"
52+
]
53+
},
54+
"execution_count": 4,
55+
"metadata": {},
56+
"output_type": "execute_result"
57+
}
58+
],
59+
"source": [
60+
"%%time\n",
61+
"year_month_day_directories = list_directories(path=EUMETSAT_PATH, pattern='*/*/*')\n",
62+
"n = len(year_month_day_directories)\n",
63+
"n"
64+
]
65+
},
66+
{
67+
"cell_type": "code",
68+
"execution_count": 5,
69+
"id": "a422f554-a8c1-4e48-9070-54d9a74cbf83",
70+
"metadata": {},
71+
"outputs": [
72+
{
73+
"name": "stdout",
74+
"output_type": "stream",
75+
"text": [
76+
"613/613: /mnt/storage_a/data/ocf/solar_pv_nowcasting/nowcasting_dataset_pipeline/satellite/EUMETSAT/SEVIRI_RSS/native/2020/02/09"
77+
]
78+
}
79+
],
80+
"source": [
81+
"for i, year_month_day_directory in enumerate(year_month_day_directories):\n",
82+
" print(f'\\r{i+1:3d}/{n:3d}: {year_month_day_directory}', end='', flush=True)\n",
83+
" \n",
84+
" # Find all the '.nat' and '.nat.bz2' files:\n",
85+
" files_for_day = [x for x in year_month_day_directory.glob('*/*/*.*') if '.nat' in x.suffixes]\n",
86+
" \n",
87+
" # Move the files:\n",
88+
" for file in files_for_day:\n",
89+
" target_filename = year_month_day_directory / file.name\n",
90+
" file.rename(target_filename)\n",
91+
" \n",
92+
" # Remove the empty hour/day directories:\n",
93+
" for minute_dir in list_directories(year_month_day_directory, '*/*'):\n",
94+
" minute_dir.rmdir()\n",
95+
" for hour_dir in list_directories(year_month_day_directory, '*'):\n",
96+
" hour_dir.rmdir()"
97+
]
98+
}
99+
],
100+
"metadata": {
101+
"kernelspec": {
102+
"display_name": "nowcasting_dataset",
103+
"language": "python",
104+
"name": "nowcasting_dataset"
105+
},
106+
"language_info": {
107+
"codemirror_mode": {
108+
"name": "ipython",
109+
"version": 3
110+
},
111+
"file_extension": ".py",
112+
"mimetype": "text/x-python",
113+
"name": "python",
114+
"nbconvert_exporter": "python",
115+
"pygments_lexer": "ipython3",
116+
"version": "3.9.7"
117+
}
118+
},
119+
"nbformat": 4,
120+
"nbformat_minor": 5
121+
}

0 commit comments

Comments
 (0)