anta-database 0.3.2__tar.gz → 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {anta_database-0.3.2 → anta_database-0.3.3}/PKG-INFO +1 -1
  2. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/compiling/compile.py +5 -3
  3. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/compiling/reconnect.py +1 -1
  4. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/database/database.py +20 -16
  5. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/indexing/index_database.py +24 -11
  6. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/plotting/plotting.py +109 -70
  7. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database.egg-info/PKG-INFO +1 -1
  8. {anta_database-0.3.2 → anta_database-0.3.3}/.github/workflows/deploy.yml +0 -0
  9. {anta_database-0.3.2 → anta_database-0.3.3}/.github/workflows/release.yml +0 -0
  10. {anta_database-0.3.2 → anta_database-0.3.3}/.gitignore +0 -0
  11. {anta_database-0.3.2 → anta_database-0.3.3}/LICENSE +0 -0
  12. {anta_database-0.3.2 → anta_database-0.3.3}/README.md +0 -0
  13. {anta_database-0.3.2 → anta_database-0.3.3}/ROADMAP.md +0 -0
  14. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/__init__.py +0 -0
  15. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/anta_database.py +0 -0
  16. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/compiling/__init__.py +0 -0
  17. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/ANT_Basins_IMBIE2_v1.6.cpg +0 -0
  18. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/ANT_Basins_IMBIE2_v1.6.dbf +0 -0
  19. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/ANT_Basins_IMBIE2_v1.6.prj +0 -0
  20. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/ANT_Basins_IMBIE2_v1.6.shp +0 -0
  21. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/ANT_Basins_IMBIE2_v1.6.shx +0 -0
  22. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/GL.pkl +0 -0
  23. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/centeroid_coords_basins.cpg +0 -0
  24. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/centeroid_coords_basins.dbf +0 -0
  25. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/centeroid_coords_basins.prj +0 -0
  26. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/centeroid_coords_basins.shp +0 -0
  27. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/centeroid_coords_basins.shx +0 -0
  28. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/data/site-coords.pkl +0 -0
  29. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/database/__init__.py +0 -0
  30. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/figures/AntA_38ka.png +0 -0
  31. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/indexing/__init__.py +0 -0
  32. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database/plotting/__init__.py +0 -0
  33. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database.egg-info/SOURCES.txt +0 -0
  34. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database.egg-info/dependency_links.txt +0 -0
  35. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database.egg-info/requires.txt +0 -0
  36. {anta_database-0.3.2 → anta_database-0.3.3}/anta_database.egg-info/top_level.txt +0 -0
  37. {anta_database-0.3.2 → anta_database-0.3.3}/book/_config.yml +0 -0
  38. {anta_database-0.3.2 → anta_database-0.3.3}/book/_toc.yml +0 -0
  39. {anta_database-0.3.2 → anta_database-0.3.3}/book/advanced.md +0 -0
  40. {anta_database-0.3.2 → anta_database-0.3.3}/book/contact.md +0 -0
  41. {anta_database-0.3.2 → anta_database-0.3.3}/book/contribute.md +0 -0
  42. {anta_database-0.3.2 → anta_database-0.3.3}/book/figures/Overview_all.png +0 -0
  43. {anta_database-0.3.2 → anta_database-0.3.3}/book/intro.md +0 -0
  44. {anta_database-0.3.2 → anta_database-0.3.3}/book/logo.png +0 -0
  45. {anta_database-0.3.2 → anta_database-0.3.3}/book/quick_start.ipynb +0 -0
  46. {anta_database-0.3.2 → anta_database-0.3.3}/book/references.bib +0 -0
  47. {anta_database-0.3.2 → anta_database-0.3.3}/book/requirements.txt +0 -0
  48. {anta_database-0.3.2 → anta_database-0.3.3}/pyproject.toml +0 -0
  49. {anta_database-0.3.2 → anta_database-0.3.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anta_database
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: SQLite database for the AntArchitecture Community Data
5
5
  Author: Antoine Hermant
6
6
  Author-email: antoine.hermant@etik.com
@@ -863,6 +863,8 @@ class CompileDatabase:
863
863
  max_depth[i] = depth_slice[max_idx]
864
864
  age_max_depth[i] = ds.IRH_AGE.values[max_idx]
865
865
 
866
+ age_max_depth = np.abs(age_max_depth)
867
+ max_depth = np.abs(max_depth)
866
868
  flight_id = ds.attrs["flight ID"]
867
869
  acq_year = ds.attrs["acquisition year"]
868
870
  project = ds.attrs["project"]
@@ -872,10 +874,10 @@ class CompileDatabase:
872
874
  df = gpd.GeoDataFrame({
873
875
  "geometry": [Point(x, y) for x, y in zip(ds.PSX.values, ds.PSY.values)],
874
876
  "irh_num": N.astype('int16'),
875
- "max_age": age_max_depth.astype('int16'),
877
+ "max_age": age_max_depth.astype('int32'),
876
878
  "max_depth": max_depth.astype('int16'),
877
- "flight_id": [flight_id] * len(N),
878
- "doi_data": [doi_data] * len(N),
879
+ # "flight_id": [flight_id] * len(N),
880
+ # "doi_data": [doi_data] * len(N),
879
881
  }, crs="EPSG:3031")
880
882
 
881
883
  all_dfs.append(df)
@@ -43,7 +43,7 @@ class Reconnect:
43
43
 
44
44
 
45
45
  def process(self, df_connect: pd.DataFrame, tree, file_path: str):
46
- data_dir = self._db.db_dir
46
+ data_dir = self._db._db_dir
47
47
  full_path = os.path.join(data_dir, file_path)
48
48
  with h5py.File(full_path, 'a') as f:
49
49
  with xr.open_dataset(f, engine='h5netcdf') as ds:
@@ -92,11 +92,13 @@ class Database:
92
92
  LEFT JOIN
93
93
  variables v ON dv.variable_id = v.id
94
94
  LEFT JOIN
95
- dataset_ages da ON d.id = da.dataset_id
95
+ dataset_ages da ON d.id = da.dataset_id AND v.name = 'IRH_DEPTH'
96
96
  LEFT JOIN
97
97
  ages a ON da.age_id = a.id
98
98
  LEFT JOIN
99
- regions r ON da.region_id = r.id
99
+ dataset_regions dr ON d.id = dr.dataset_id
100
+ LEFT JOIN
101
+ regions r ON dr.region_id = r.id
100
102
  '''
101
103
  conditions = []
102
104
  params = []
@@ -415,21 +417,21 @@ class Database:
415
417
  Helper method to build the SQL query and parameters for filtering.
416
418
  Returns the query string and parameters list.
417
419
  """
418
- select_clause = 's.name AS dataset, \
420
+ select_clause = "s.name AS dataset, \
419
421
  s.citation, \
420
422
  s.DOI_dataset, \
421
423
  s.DOI_publication, \
422
424
  institutes_list.institutes, \
423
425
  projects_list.projects, \
424
426
  d.acq_year, \
425
- a.age, \
426
- a.age_unc, \
427
+ CASE WHEN v.name = 'IRH_DEPTH' THEN a.age ELSE NULL END AS age, \
428
+ CASE WHEN v.name = 'IRH_DEPTH' THEN a.age_unc ELSE NULL END AS age_unc, \
427
429
  v.name AS var, \
428
430
  d.flight_id, \
429
431
  r.region, \
430
432
  r.IMBIE_basin, \
431
433
  radar_instruments_list.radar_instruments \
432
- '
434
+ "
433
435
  query = f'''
434
436
  SELECT {select_clause}
435
437
  FROM
@@ -474,11 +476,13 @@ class Database:
474
476
  LEFT JOIN
475
477
  variables v ON dv.variable_id = v.id
476
478
  LEFT JOIN
477
- dataset_ages da ON d.id = da.dataset_id
479
+ dataset_ages da ON d.id = da.dataset_id AND v.name = 'IRH_DEPTH'
478
480
  LEFT JOIN
479
481
  ages a ON da.age_id = a.id
480
482
  LEFT JOIN
481
- regions r ON da.region_id = r.id
483
+ dataset_regions dr ON d.id = dr.dataset_id
484
+ LEFT JOIN
485
+ regions r ON dr.region_id = r.id
482
486
  '''
483
487
  conditions = []
484
488
  params = []
@@ -536,21 +540,21 @@ class Database:
536
540
  retain_query: Optional[bool] = True,
537
541
  ) -> 'MetadataResult':
538
542
 
539
- select_clause = 's.name AS dataset, \
543
+ select_clause = "s.name AS dataset, \
540
544
  s.citation, \
541
545
  s.DOI_dataset, \
542
546
  s.DOI_publication, \
543
547
  institutes_list.institutes, \
544
548
  projects_list.projects, \
545
549
  d.acq_year, \
546
- a.age, \
547
- a.age_unc, \
550
+ CASE WHEN v.name = 'IRH_DEPTH' THEN a.age ELSE NULL END AS age, \
551
+ CASE WHEN v.name = 'IRH_DEPTH' THEN a.age_unc ELSE NULL END AS age_unc, \
548
552
  v.name AS var, \
549
553
  d.flight_id, \
550
554
  r.region, \
551
555
  r.IMBIE_basin, \
552
556
  radar_instruments_list.radar_instruments \
553
- '
557
+ "
554
558
  query, params = self._build_query_and_params(age, var, dataset, institute, project, acquisition_year, flight_id, region, IMBIE_basin, radar_instrument, select_clause)
555
559
 
556
560
  conn = sqlite3.connect(self._file_db_path)
@@ -686,18 +690,18 @@ class Database:
686
690
 
687
691
  def get_files(
688
692
  self,
689
- metadata: Union[None, Dict, 'MetadataResult'] = None,
690
- data_dir: Union[None, str] = None,
693
+ metadata: Optional[Union[None, Dict, 'MetadataResult']] = None,
694
+ data_dir: Optional[Union[None, str]] = None,
691
695
  ):
692
696
 
693
697
  md = metadata or self._md
694
698
  if not md:
695
- print('Please provide metadata of the files you want to generate the data from. Exiting...')
699
+ print('Please provide metadata of the files you want to generate the data from.')
696
700
  return
697
701
 
698
702
  data_dir = data_dir or self._db_dir
699
703
  if not data_dir:
700
- print('No data directory provided. Exiting...')
704
+ print('No data directory provided.')
701
705
  return
702
706
 
703
707
  file_paths = self._get_file_paths_from_metadata(metadata=md)
@@ -126,11 +126,9 @@ class IndexDatabase:
126
126
  CREATE TABLE IF NOT EXISTS dataset_ages (
127
127
  dataset_id INTEGER,
128
128
  age_id INTEGER,
129
- region_id INTEGER,
130
129
  FOREIGN KEY (dataset_id) REFERENCES datasets (id),
131
130
  FOREIGN KEY (age_id) REFERENCES ages (id),
132
- FOREIGN KEY (region_id) REFERENCES regions (id),
133
- PRIMARY KEY (dataset_id, age_id, region_id)
131
+ PRIMARY KEY (dataset_id, age_id)
134
132
  )
135
133
  ''')
136
134
 
@@ -164,6 +162,16 @@ class IndexDatabase:
164
162
  )
165
163
  ''')
166
164
 
165
+ cursor.execute('''
166
+ CREATE TABLE IF NOT EXISTS dataset_regions (
167
+ dataset_id INTEGER,
168
+ region_id INTEGER,
169
+ FOREIGN KEY (dataset_id) REFERENCES datasets (id),
170
+ FOREIGN KEY (region_id) REFERENCES regions (id),
171
+ PRIMARY KEY (dataset_id, region_id)
172
+ )
173
+ ''')
174
+
167
175
  for f in tqdm(h5_files, desc="Indexing files"):
168
176
  _, file_name = os.path.split(f)
169
177
 
@@ -281,7 +289,7 @@ class IndexDatabase:
281
289
  # Insert variables
282
290
  var_list = ['ICE_THK', 'SURF_ELEV', 'BED_ELEV', 'BASAL_UNIT', 'IRH_NUM', 'IRH_DEPTH']
283
291
  for var in var_list:
284
- if var in ds_vars or var == 'IRH_DEPTH':
292
+ if var in ds_vars:
285
293
  cursor.execute('INSERT OR IGNORE INTO variables (name) VALUES (?)', (var,))
286
294
  var_id = cursor.execute('SELECT id FROM variables WHERE name = ?', (var,)).fetchone()[0]
287
295
  cursor.execute('''
@@ -294,13 +302,18 @@ class IndexDatabase:
294
302
  for age, age_unc in age_uncs.iterrows():
295
303
  cursor.execute('INSERT OR IGNORE INTO ages (age, age_unc) VALUES (?, ?)', (str(age), str(age_unc['age_unc'])))
296
304
  age_id = cursor.execute('SELECT id FROM ages WHERE age = ? AND age_unc = ?', (str(age), str(age_unc['age_unc']))).fetchone()[0]
297
- for basin, region in basin_mapping.items():
298
- cursor.execute('INSERT OR IGNORE INTO regions (region, IMBIE_basin) VALUES (?, ?)', (region, basin))
299
- region_id = cursor.execute('SELECT id FROM regions WHERE region = ? AND IMBIE_basin = ?', (region, basin)).fetchone()[0]
300
- cursor.execute('''
301
- INSERT OR IGNORE INTO dataset_ages (dataset_id, age_id, region_id)
302
- VALUES (?, ?, ?)
303
- ''', (dataset_row_id, age_id, region_id))
305
+ cursor.execute('''
306
+ INSERT OR IGNORE INTO dataset_ages (dataset_id, age_id)
307
+ VALUES (?, ?)
308
+ ''', (dataset_row_id, age_id))
309
+
310
+ for basin, region in basin_mapping.items():
311
+ cursor.execute('INSERT OR IGNORE INTO regions (region, IMBIE_basin) VALUES (?, ?)', (region, basin))
312
+ region_id = cursor.execute('SELECT id FROM regions WHERE region = ? AND IMBIE_basin = ?', (region, basin)).fetchone()[0]
313
+ cursor.execute('''
314
+ INSERT OR IGNORE INTO dataset_regions (dataset_id, region_id)
315
+ VALUES (?, ?)
316
+ ''', (dataset_row_id, region_id))
304
317
 
305
318
  conn.commit()
306
319
  conn.close()
@@ -64,11 +64,12 @@ class Plotting:
64
64
  metadata: Union[None, Dict, 'MetadataResult'] = None,
65
65
  downscale_factor: Optional[int] = None,
66
66
  title: Optional[str] = None,
67
- xlim: tuple = (None, None),
68
- ylim: tuple = (None, None),
67
+ xlim: Optional[tuple] = (None, None),
68
+ ylim: Optional[tuple] = (None, None),
69
+ vmin: Optional[float] = None,
70
+ vmax: Optional[float] = None,
69
71
  scale_factor: float = 1.0,
70
72
  marker_size: Optional[float] = 0.5,
71
- latex: bool = False,
72
73
  cmap: Optional['LinearSegmentedColormap'] = None,
73
74
  grounding_line: Optional[bool] = True,
74
75
  basins: Optional[bool] = True,
@@ -86,8 +87,9 @@ class Plotting:
86
87
  title=title,
87
88
  xlim=xlim,
88
89
  ylim=ylim,
90
+ vmin=vmin,
91
+ vmax=vmax,
89
92
  scale_factor=scale_factor,
90
- latex=latex,
91
93
  cmap=cmap,
92
94
  grounding_line=grounding_line,
93
95
  basins=basins,
@@ -100,11 +102,12 @@ class Plotting:
100
102
  metadata: Union[None, Dict, 'MetadataResult'] = None,
101
103
  downscale_factor: Optional[int] = None,
102
104
  title: Optional[str] = None,
103
- xlim: tuple = (None, None),
104
- ylim: tuple = (None, None),
105
+ xlim: Optional[tuple] = (None, None),
106
+ ylim: Optional[tuple] = (None, None),
107
+ vmin: Optional[float] = None,
108
+ vmax: Optional[float] = None,
105
109
  scale_factor: float = 1.0,
106
110
  marker_size: Optional[float] = 0.1,
107
- latex: bool = False,
108
111
  cmap: Optional['LinearSegmentedColormap'] = None,
109
112
  grounding_line: Optional[bool] = True,
110
113
  basins: Optional[bool] = True,
@@ -122,8 +125,9 @@ class Plotting:
122
125
  title=title,
123
126
  xlim=xlim,
124
127
  ylim=ylim,
128
+ vmin=vmin,
129
+ vmax=vmax,
125
130
  scale_factor=scale_factor,
126
- latex=latex,
127
131
  cmap=cmap,
128
132
  grounding_line=grounding_line,
129
133
  basins=basins,
@@ -136,11 +140,12 @@ class Plotting:
136
140
  metadata: Union[None, Dict, 'MetadataResult'] = None,
137
141
  downscale_factor: Optional[int] = None,
138
142
  title: Optional[str] = None,
139
- xlim: tuple = (None, None),
140
- ylim: tuple = (None, None),
143
+ xlim: Optional[tuple] = (None, None),
144
+ ylim: Optional[tuple] = (None, None),
145
+ vmin: Optional[float] = None,
146
+ vmax: Optional[float] = None,
141
147
  scale_factor: float = 1.0,
142
148
  marker_size: Optional[float] = 0.1,
143
- latex: bool = False,
144
149
  cmap: Optional['LinearSegmentedColormap'] = None,
145
150
  grounding_line: Optional[bool] = True,
146
151
  basins: Optional[bool] = True,
@@ -159,7 +164,8 @@ class Plotting:
159
164
  title=title,
160
165
  xlim=xlim,
161
166
  ylim=ylim,
162
- latex=latex,
167
+ vmin=vmin,
168
+ vmax=vmax,
163
169
  cmap=cmap,
164
170
  grounding_line=grounding_line,
165
171
  basins=basins,
@@ -172,11 +178,12 @@ class Plotting:
172
178
  metadata: Union[None, Dict, 'MetadataResult'] = None,
173
179
  downscale_factor: Optional[int] = None,
174
180
  title: Optional[str] = None,
175
- xlim: tuple = (None, None),
176
- ylim: tuple = (None, None),
181
+ xlim: Optional[tuple] = (None, None),
182
+ ylim: Optional[tuple] = (None, None),
183
+ vmin: Optional[float] = None,
184
+ vmax: Optional[float] = None,
177
185
  scale_factor: float = 1.0,
178
186
  marker_size: Optional[float] = 0.3,
179
- latex: bool = False,
180
187
  cmap: Optional['LinearSegmentedColormap'] = None,
181
188
  grounding_line: Optional[bool] = True,
182
189
  basins: Optional[bool] = True,
@@ -193,9 +200,10 @@ class Plotting:
193
200
  title=title,
194
201
  xlim=xlim,
195
202
  ylim=ylim,
203
+ vmin=vmin,
204
+ vmax=vmax,
196
205
  scale_factor=scale_factor,
197
206
  marker_size=marker_size,
198
- latex=latex,
199
207
  cmap=cmap,
200
208
  grounding_line=grounding_line,
201
209
  basins=basins,
@@ -203,16 +211,16 @@ class Plotting:
203
211
  save=save,
204
212
  )
205
213
 
206
- def transect(
214
+ def transect_1D(
207
215
  self,
208
216
  metadata: Union[None, Dict, 'MetadataResult'] = None,
217
+ elevation: Optional[bool] = False,
209
218
  downscale_factor: Optional[int] = None,
210
219
  title: Optional[str] = None,
211
- xlim: tuple = (None, None),
212
- ylim: tuple = (3500, 0),
220
+ xlim: Optional[tuple] = (None, None),
221
+ ylim: Optional[tuple] = (None, None),
213
222
  scale_factor: float = 1.0,
214
223
  marker_size: Optional[float] = 2,
215
- latex: bool = False,
216
224
  cmap: Optional['LinearSegmentedColormap'] = None,
217
225
  grounding_line: Optional[bool] = True,
218
226
  basins: Optional[bool] = True,
@@ -223,7 +231,8 @@ class Plotting:
223
231
  Plot the color-coded values of the given variable on Antarcitic map
224
232
  """
225
233
  self._base_plot(
226
- color_by='transect',
234
+ color_by='transect_1D',
235
+ elevation=elevation,
227
236
  metadata=metadata,
228
237
  downscale_factor=downscale_factor,
229
238
  title=title,
@@ -231,7 +240,6 @@ class Plotting:
231
240
  ylim=ylim,
232
241
  scale_factor=scale_factor,
233
242
  marker_size=marker_size,
234
- latex=latex,
235
243
  cmap=cmap,
236
244
  grounding_line=grounding_line,
237
245
  basins=basins,
@@ -250,22 +258,24 @@ class Plotting:
250
258
  plt.close()
251
259
 
252
260
  def _base_plot(
253
- self,
254
- metadata: Union[None, Dict, 'MetadataResult'] = None,
255
- downscale_factor: Optional[int] = None,
256
- title: Optional[str] = None,
257
- xlim: tuple = (None, None),
258
- ylim: tuple = (None, None),
259
- scale_factor: float = 1.0,
260
- marker_size: Optional[float] = 0.1,
261
- latex: bool = False,
262
- save: Optional[str] = None,
263
- color_by: str = 'dataset', # 'dataset', 'flight_id', 'depth', 'density'
264
- cmap: Optional['LinearSegmentedColormap'] = None,
265
- grounding_line: Optional[bool] = True,
266
- basins: Optional[bool] = True,
267
- stations: Optional[bool] = True,
268
- ncol: Optional[int] = None,
261
+ self,
262
+ metadata: Union[None, Dict, 'MetadataResult'] = None,
263
+ elevation: Optional[bool] = False,
264
+ downscale_factor: Optional[int] = None,
265
+ title: Optional[str] = None,
266
+ xlim: Optional[tuple] = (None, None),
267
+ ylim: Optional[tuple] = (None, None),
268
+ vmin: Optional[float] = None,
269
+ vmax: Optional[float] = None,
270
+ scale_factor: float = 1.0,
271
+ marker_size: Optional[float] = 0.1,
272
+ save: Optional[str] = None,
273
+ color_by: str = 'dataset', # 'dataset', 'flight_id', 'depth', 'density'
274
+ cmap: Optional['LinearSegmentedColormap'] = None,
275
+ grounding_line: Optional[bool] = True,
276
+ basins: Optional[bool] = True,
277
+ stations: Optional[bool] = True,
278
+ ncol: Optional[int] = None,
269
279
  ) -> None:
270
280
  # --- Setup ---
271
281
  if metadata is None:
@@ -277,8 +287,6 @@ class Plotting:
277
287
 
278
288
  total_traces = len(metadata['flight_id'])
279
289
 
280
- # if latex:
281
-
282
290
  if not self._pre_plot_check(metadata):
283
291
  return
284
292
 
@@ -292,7 +300,7 @@ class Plotting:
292
300
  if basins:
293
301
  grounding_line = False
294
302
  # --- Plot Grounding Line ---
295
- if True and color_by != 'transect': # FIXME
303
+ if True and color_by != 'transect_1D': # FIXME
296
304
  gl = pd.read_pickle(self._gl_path)
297
305
  ax.plot(gl.x/1000, gl.y/1000, linewidth=1, color='k')
298
306
 
@@ -302,8 +310,6 @@ class Plotting:
302
310
  values = None
303
311
  label = None
304
312
  extend = None
305
- vmin = 0
306
- vmax = 10
307
313
 
308
314
  if color_by == 'dataset':
309
315
  if not title:
@@ -442,32 +448,32 @@ class Plotting:
442
448
  if cmap == None:
443
449
  cmap = cmaps.bukavu
444
450
  extend = 'both'
445
- vmin = -1000
446
- vmax = 1000
451
+ if not vmin: vmin = -1000
452
+ if not vmax: vmax = 1000
447
453
  if not title:
448
454
  title = f'AntADatabase Bed Elevation'
449
455
  elif var == 'ICE_THK':
450
456
  if cmap == None:
451
457
  cmap = cmaps.torch_r
452
458
  extend = 'max'
453
- vmin = 0
454
- vmax = 4000
459
+ if not vmin: vmin = 0
460
+ if not vmax: vmax = 4000
455
461
  if not title:
456
462
  title = f'AntADatabase Ice Thickness'
457
463
  elif var == 'SURF_ELEV':
458
464
  if cmap == None:
459
465
  cmap = cmaps.torch_r
460
466
  extend = 'max'
461
- vmin = 2000
462
- vmax = 4000
467
+ if not vmin: vmin = 2000
468
+ if not vmax: vmax = 4000
463
469
  if not title:
464
470
  title = f'AntADatabase Surface Elevation'
465
471
  elif var == 'BASAL_UNIT':
466
472
  if cmap == None:
467
473
  cmap = cmaps.torch_r
468
474
  extend = 'both'
469
- vmin = 2000
470
- vmax = 4000
475
+ if not vmin: vmin = 2000
476
+ if not vmax: vmax = 400
471
477
  if not title:
472
478
  title = f'AntADatabase Basal Unit'
473
479
  scatter = plt.scatter(df['PSX']/1000, df['PSY']/1000, c=df[var], cmap=cmap, s=marker_size, vmin=vmin, vmax=vmax, linewidths=0, rasterized=True)
@@ -478,8 +484,6 @@ class Plotting:
478
484
  if cmap == None:
479
485
  cmap = cmaps.torch_r
480
486
  extend = 'both'
481
- vmin = None
482
- vmax = None
483
487
  age = list(metadata['age'])
484
488
  if not title:
485
489
  title = f'AntADatabase IRH Depth'
@@ -493,8 +497,6 @@ class Plotting:
493
497
  if cmap == None:
494
498
  cmap = cmaps.torch_r
495
499
  extend = 'both'
496
- vmin = None
497
- vmax = None
498
500
  age = list(metadata['age'])
499
501
  if len(age) > 1:
500
502
  print('WARNING: Multiple layers provided: ', age,
@@ -508,7 +510,7 @@ class Plotting:
508
510
  for age in metadata['age']:
509
511
  scatter = plt.scatter(df['PSX']/1000, df['PSY']/1000, c=df[int(age)], cmap=cmap, s=marker_size, vmin=vmin, vmax=vmax, linewidths=0, rasterized=True)
510
512
 
511
- if color_by == 'transect':
513
+ if color_by == 'transect_1D':
512
514
  flight_id = list(metadata['flight_id'])
513
515
  if len(flight_id) > 1:
514
516
  flight_id = flight_id[0]
@@ -519,7 +521,7 @@ class Plotting:
519
521
 
520
522
  metadata_impl = self._db.query(flight_id=flight_id, dataset=metadata['dataset'], retain_query=False)
521
523
  if not title:
522
- title = f'Transect {metadata['flight_id'][0]} from {metadata['reference'][0]}'
524
+ title = f'Transect {metadata_impl['flight_id'][0]} from {metadata_impl['reference'][0]}'
523
525
 
524
526
  f = self._db._get_file_paths_from_metadata(metadata_impl)[0]
525
527
  full_path = os.path.join(self._db._db_dir, f)
@@ -530,15 +532,49 @@ class Plotting:
530
532
  print('Distance not in varibles, cannot plot along transect')
531
533
  return
532
534
 
535
+ if elevation:
536
+ if 'SURF_ELEV' in ds.variables:
537
+ ds['IRH_DEPTH'] = ds.SURF_ELEV - ds.IRH_DEPTH
538
+
539
+ elif 'ICE_THK' in ds.variables and 'BED_ELEV' in ds.variables:
540
+ ds['SURF_ELEV'] = (ds.ICE_THK + ds.BED_ELEV) - ds.IRH_DEPTH
541
+ ds['IRH_DEPTH'] = ds.SURF_ELEV - ds.IRH_DEPTH
542
+ else:
543
+ print('Cannot plot IRH Elevation from the variables in the file, missing either ICE_THK and BED_ELEV or SURF_ELEV')
544
+ return
545
+
533
546
  cmap = self._custom_cmap_density()
534
- colors = [cmap(i) for i in np.linspace(0.1, 0.9, ds.sizes['IRH_AGE'])]
535
- for age, color in zip(ds.IRH_AGE, colors):
547
+ colors = [cmap(i) for i in np.linspace(0.1, 0.9, len(metadata_impl['age']))]
548
+ for age, color in zip(list(map(int, metadata['age'])), colors):
549
+ if age not in ds.IRH_AGE:
550
+ print(f'{metadata_impl['flight_id'][0]} does not contain age {age}, skipping')
551
+ continue
552
+
536
553
  ax.scatter(ds.Distance/1000, ds.IRH_DEPTH.sel(IRH_AGE=age),
537
- color=color, s=marker_size, linewidths=0.1)
538
- plt.plot([], [], color=color, label=age.values, linewidth=3)
539
- # ds.IRH_DEPTH.sel(IRH_AGE=age).where(~np.isnan(ds.IRH_DEPTH.sel(IRH_AGE=age)), drop=True).plot()
540
- scatter = ax.scatter(ds.Distance/1000, ds.ICE_THK, color='k', s=marker_size, linewidths=0.1)
541
- plt.plot([], [], color='k', label='Bed Depth', linewidth=3)
554
+ color=color, s=marker_size, linewidths=0.1)
555
+ plt.plot([], [], color=color, label=age, linewidth=3)
556
+
557
+ if elevation:
558
+ if 'BED_ELEV' in ds.variables:
559
+ scatter = ax.scatter(ds.Distance/1000, ds.BED_ELEV, color='k', s=marker_size, linewidths=0.1)
560
+ plt.plot([], [], color='k', label='Bed Elevation', linewidth=3)
561
+ elif 'ICE_THK' in ds.variables and 'SURF_ELEV' in ds.variables:
562
+ ds['BED_ELEV'] = ds.SURF_ELEV - ds.ICE_THK
563
+ scatter = ax.scatter(ds.Distance/1000, ds.BED_ELEV, color='k', s=marker_size, linewidths=0.1)
564
+ plt.plot([], [], color='k', label='Bed Elevation', linewidth=3)
565
+ else:
566
+ print('Cannot plot Bed Elevation from the variables in the file')
567
+ ax.scatter(ds.Distance/1000, ds.SURF_ELEV, color='grey', s=marker_size, linewidths=0.1)
568
+ plt.plot([], [], color='grey', label='Surface Elevation', linewidth=3)
569
+
570
+ else:
571
+ scatter = ax.scatter(ds.Distance/1000, ds.ICE_THK, color='k', s=marker_size, linewidths=0.1)
572
+ plt.plot([], [], color='k', label='Bed Depth', linewidth=3)
573
+
574
+ if elevation:
575
+ ylim = (ds.BED_ELEV.min() - 200, ds.SURF_ELEV.max()+200) if ylim == (None, None) else ylim
576
+ else:
577
+ ylim = (ds.ICE_THK.max() + 200, 0) if ylim == (None, None) else ylim
542
578
 
543
579
  if ncol == None:
544
580
  if ds.sizes['IRH_AGE'] > 7:
@@ -579,7 +615,7 @@ class Plotting:
579
615
 
580
616
  ax.set_xlim(*xlim)
581
617
  ax.set_ylim(*ylim)
582
- if color_by != 'transect':
618
+ if color_by != 'transect_1D':
583
619
  x0, x1 = ax.get_xlim() if xlim == (None, None) else xlim
584
620
  y0, y1 = ax.get_ylim() if ylim == (None, None) else ylim
585
621
  x_extent = x1 - x0
@@ -607,16 +643,19 @@ class Plotting:
607
643
  cbar.ax.xaxis.set_ticks_position('bottom')
608
644
  if label:
609
645
  cbar.set_label(label)
610
- elif color_by == 'transect':
646
+ elif color_by == 'transect_1D':
611
647
  ax.legend(ncols=2)
612
- ax.set_xlabel('Distance [km]')
613
- ax.set_ylabel('Depth below surface [m]')
648
+ ax.set_xlabel('Distance along transect [km]')
649
+ if elevation:
650
+ ax.set_ylabel('Elevation above sea level [m]')
651
+ else:
652
+ ax.set_ylabel('Depth below surface [m]')
614
653
  plt.gcf().set_size_inches(10 * scale_factor, 10 * 2/3)
615
654
 
616
655
  plt.tight_layout()
617
656
 
618
657
  # --- Plot IMBIE basins ---
619
- if basins and color_by != 'transect':
658
+ if basins and color_by != 'transect_1D':
620
659
  sf_basins = shapefile.Reader(self._imbie_path)
621
660
  basin_patches = []
622
661
 
@@ -667,7 +706,7 @@ class Plotting:
667
706
  )]
668
707
  )
669
708
  # --- Plot ice core sites ---
670
- if stations and color_by != 'transect':
709
+ if stations and color_by != 'transect_1D':
671
710
  site_coords = pd.read_pickle(self._site_coords_path)
672
711
  for i in site_coords.index:
673
712
  site = site_coords.loc[i]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anta_database
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: SQLite database for the AntArchitecture Community Data
5
5
  Author: Antoine Hermant
6
6
  Author-email: antoine.hermant@etik.com
File without changes
File without changes
File without changes
File without changes
File without changes