Emma Scharfmann commited on
Commit
71ebab9
·
1 Parent(s): a78732b
.gitignore CHANGED
@@ -2,4 +2,5 @@
2
  __pycache__/
3
  *.pyc
4
  .npz
5
- ic_cache/
 
 
2
  __pycache__/
3
  *.pyc
4
  .npz
5
+ ic_cache/
6
+ .idea/
.idea/AIFS-space.iml DELETED
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="PYTHON_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/.venv" />
6
- </content>
7
- <orderEntry type="jdk" jdkName="Python 3.12 (AIFS-space)" jdkType="Python SDK" />
8
- <orderEntry type="sourceFolder" forTests="false" />
9
- </component>
10
- <component name="PyDocumentationSettings">
11
- <option name="format" value="NUMPY" />
12
- <option name="myDocStringFormat" value="NumPy" />
13
- </component>
14
- </module>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/AIFS-space.iml" filepath="$PROJECT_DIR$/.idea/AIFS-space.iml" />
6
- </modules>
7
- </component>
8
- </project>
 
 
 
 
 
 
 
 
 
aifs/initial_conditions.py CHANGED
@@ -53,7 +53,10 @@ def _try_load(date: datetime.datetime, cache_dir: Path):
53
  """Return ``(fields_dict, path)`` if cached, else ``(None, None)``."""
54
  path = _cache_path(date, cache_dir)
55
  if path.exists():
56
- return dict(np.load(str(path))), path
 
 
 
57
  return None, None
58
 
59
 
 
53
  """Return ``(fields_dict, path)`` if cached, else ``(None, None)``."""
54
  path = _cache_path(date, cache_dir)
55
  if path.exists():
56
+ try:
57
+ return dict(np.load(str(path))), path
58
+ except Exception:
59
+ path.unlink()
60
  return None, None
61
 
62
 
app.py CHANGED
@@ -20,6 +20,13 @@ import tempfile
20
 
21
  from aifs.device import device_label
22
 
 
 
 
 
 
 
 
23
 
24
  PLOTTABLE_FIELDS = [
25
  "100u", "100v", "10u", "10v", "2t", "msl", "sp", "tcw", "swh", "mwp",
 
20
 
21
  from aifs.device import device_label
22
 
23
+ import shutil
24
+
25
+ # Clear corrupted IC cache on startup
26
+ if os.path.exists("ic_cache"):
27
+ shutil.rmtree("ic_cache")
28
+ os.makedirs("ic_cache", exist_ok=True)
29
+
30
 
31
  PLOTTABLE_FIELDS = [
32
  "100u", "100v", "10u", "10v", "2t", "msl", "sp", "tcw", "swh", "mwp",