anta-database 0.3.0__tar.gz → 0.3.2__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.0 → anta_database-0.3.2}/PKG-INFO +3 -1
  2. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/database/database.py +6 -2
  3. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/plotting/plotting.py +65 -26
  4. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database.egg-info/PKG-INFO +3 -1
  5. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database.egg-info/requires.txt +2 -0
  6. {anta_database-0.3.0 → anta_database-0.3.2}/pyproject.toml +2 -0
  7. {anta_database-0.3.0 → anta_database-0.3.2}/.github/workflows/deploy.yml +0 -0
  8. {anta_database-0.3.0 → anta_database-0.3.2}/.github/workflows/release.yml +0 -0
  9. {anta_database-0.3.0 → anta_database-0.3.2}/.gitignore +0 -0
  10. {anta_database-0.3.0 → anta_database-0.3.2}/LICENSE +0 -0
  11. {anta_database-0.3.0 → anta_database-0.3.2}/README.md +0 -0
  12. {anta_database-0.3.0 → anta_database-0.3.2}/ROADMAP.md +0 -0
  13. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/__init__.py +0 -0
  14. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/anta_database.py +0 -0
  15. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/compiling/__init__.py +0 -0
  16. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/compiling/compile.py +0 -0
  17. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/compiling/reconnect.py +0 -0
  18. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/ANT_Basins_IMBIE2_v1.6.cpg +0 -0
  19. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/ANT_Basins_IMBIE2_v1.6.dbf +0 -0
  20. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/ANT_Basins_IMBIE2_v1.6.prj +0 -0
  21. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/ANT_Basins_IMBIE2_v1.6.shp +0 -0
  22. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/ANT_Basins_IMBIE2_v1.6.shx +0 -0
  23. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/GL.pkl +0 -0
  24. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/centeroid_coords_basins.cpg +0 -0
  25. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/centeroid_coords_basins.dbf +0 -0
  26. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/centeroid_coords_basins.prj +0 -0
  27. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/centeroid_coords_basins.shp +0 -0
  28. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/centeroid_coords_basins.shx +0 -0
  29. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/data/site-coords.pkl +0 -0
  30. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/database/__init__.py +0 -0
  31. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/figures/AntA_38ka.png +0 -0
  32. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/indexing/__init__.py +0 -0
  33. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/indexing/index_database.py +0 -0
  34. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database/plotting/__init__.py +0 -0
  35. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database.egg-info/SOURCES.txt +0 -0
  36. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database.egg-info/dependency_links.txt +0 -0
  37. {anta_database-0.3.0 → anta_database-0.3.2}/anta_database.egg-info/top_level.txt +0 -0
  38. {anta_database-0.3.0 → anta_database-0.3.2}/book/_config.yml +0 -0
  39. {anta_database-0.3.0 → anta_database-0.3.2}/book/_toc.yml +0 -0
  40. {anta_database-0.3.0 → anta_database-0.3.2}/book/advanced.md +0 -0
  41. {anta_database-0.3.0 → anta_database-0.3.2}/book/contact.md +0 -0
  42. {anta_database-0.3.0 → anta_database-0.3.2}/book/contribute.md +0 -0
  43. {anta_database-0.3.0 → anta_database-0.3.2}/book/figures/Overview_all.png +0 -0
  44. {anta_database-0.3.0 → anta_database-0.3.2}/book/intro.md +0 -0
  45. {anta_database-0.3.0 → anta_database-0.3.2}/book/logo.png +0 -0
  46. {anta_database-0.3.0 → anta_database-0.3.2}/book/quick_start.ipynb +0 -0
  47. {anta_database-0.3.0 → anta_database-0.3.2}/book/references.bib +0 -0
  48. {anta_database-0.3.0 → anta_database-0.3.2}/book/requirements.txt +0 -0
  49. {anta_database-0.3.0 → anta_database-0.3.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anta_database
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: SQLite database for the AntArchitecture Community Data
5
5
  Author: Antoine Hermant
6
6
  Author-email: antoine.hermant@etik.com
@@ -20,12 +20,14 @@ License-File: LICENSE
20
20
  Requires-Dist: pandas
21
21
  Requires-Dist: geopandas
22
22
  Requires-Dist: xarray
23
+ Requires-Dist: h5netcdf
23
24
  Requires-Dist: h5py
24
25
  Requires-Dist: pyproj
25
26
  Requires-Dist: scipy
26
27
  Requires-Dist: matplotlib
27
28
  Requires-Dist: colormaps
28
29
  Requires-Dist: tqdm
30
+ Requires-Dist: pyshp
29
31
  Dynamic: license-file
30
32
 
31
33
  <h1 align="center">
@@ -5,6 +5,7 @@ import numpy as np
5
5
  import xarray as xr
6
6
  import h5py
7
7
  from typing import Union, List, Dict, Tuple, Optional, Generator
8
+ from tqdm import tqdm
8
9
 
9
10
  from anta_database.plotting.plotting import Plotting
10
11
 
@@ -17,6 +18,7 @@ class Database:
17
18
  self._plotting = None
18
19
  self._max_displayed_flight_ids = max_displayed_flight_ids
19
20
  self._include_BM = include_BEDMAP
21
+ self._disable_tqdm = os.getenv("JUPYTER_BOOK_BUILD", False)
20
22
  self._excluded = {
21
23
  'dataset': [],
22
24
  'institute': [],
@@ -710,6 +712,7 @@ class Database:
710
712
  metadata: Union[None, Dict, 'MetadataResult'] = None,
711
713
  data_dir: Optional[str] = None,
712
714
  downscale_factor: Optional[str] = None,
715
+ disable_tqdm: bool = False,
713
716
  ) -> Generator[Tuple[pd.DataFrame, Dict]]:
714
717
  """
715
718
  Generates xarray Datasets from HDF5 files, one at a time, with lazy loading.
@@ -737,7 +740,7 @@ class Database:
737
740
  file_paths = self._get_file_paths_from_metadata(metadata=md)
738
741
  file_paths = np.unique(file_paths) # Be carefull as many pointers point to the same file
739
742
 
740
- for file_path in file_paths:
743
+ for file_path in tqdm(file_paths, desc='Generating dataframes', total=len(file_paths), unit='file', disable=disable_tqdm):
741
744
  full_path = os.path.join(data_dir, file_path)
742
745
  file_md = self._get_file_metadata(file_path)
743
746
  ds = h5py.File(full_path, 'r')
@@ -759,7 +762,8 @@ class Database:
759
762
  df[int(age)] = ds[var][::downscale_factor, irh_index]
760
763
 
761
764
  else:
762
- df[var] = ds[var][::downscale_factor]
765
+ if var in ds.keys():
766
+ df[var] = ds[var][::downscale_factor]
763
767
 
764
768
  metadata = {
765
769
  'dataset': file_md['dataset'],
@@ -1,10 +1,12 @@
1
1
  import os
2
2
  import h5py
3
3
  import pandas as pd
4
- import geopandas as gpd
5
4
  import numpy as np
6
5
  import matplotlib.pyplot as plt
7
6
  from matplotlib.colors import BoundaryNorm, ListedColormap, LinearSegmentedColormap
7
+ import shapefile
8
+ from matplotlib.patches import Polygon
9
+ from matplotlib.collections import PatchCollection
8
10
  from matplotlib import patheffects as path_effects
9
11
  import colormaps as cmaps
10
12
  from contextlib import contextmanager
@@ -22,6 +24,7 @@ class Plotting:
22
24
  self._site_coords_path = files('anta_database.data').joinpath('site-coords.pkl')
23
25
  self._imbie_path = files('anta_database.data').joinpath('ANT_Basins_IMBIE2_v1.6.shp')
24
26
  self._center_coords = files('anta_database.data').joinpath('centeroid_coords_basins.shp')
27
+ self._disable_tqdm = os.getenv("JUPYTER_BOOK_BUILD", False)
25
28
 
26
29
  def _pre_plot_check(self,
27
30
  metadata: Union[None, Dict, 'MetadataResult'] = None
@@ -206,7 +209,7 @@ class Plotting:
206
209
  downscale_factor: Optional[int] = None,
207
210
  title: Optional[str] = None,
208
211
  xlim: tuple = (None, None),
209
- ylim: tuple = (3000, None),
212
+ ylim: tuple = (3500, 0),
210
213
  scale_factor: float = 1.0,
211
214
  marker_size: Optional[float] = 2,
212
215
  latex: bool = False,
@@ -274,10 +277,7 @@ class Plotting:
274
277
 
275
278
  total_traces = len(metadata['flight_id'])
276
279
 
277
- if latex:
278
- from matplotlib import rc
279
- rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
280
- rc('text', usetex=True)
280
+ # if latex:
281
281
 
282
282
  if not self._pre_plot_check(metadata):
283
283
  return
@@ -325,7 +325,7 @@ class Plotting:
325
325
  colors.update(bedmap_colors)
326
326
 
327
327
  flight_ids = metadata['flight_id']
328
- for dataset in tqdm(datasets, desc="Plotting", total=len(datasets), unit='dataset'):
328
+ for dataset in tqdm(datasets, desc="Plotting", total=len(datasets), unit='dataset', disable=self._disable_tqdm):
329
329
  metadata_impl = self._db.query(dataset=dataset, flight_id=flight_ids, retain_query=False)
330
330
  file_paths = self._db._get_file_paths_from_metadata(metadata_impl)
331
331
  file_paths = np.unique(file_paths)
@@ -363,7 +363,7 @@ class Plotting:
363
363
  colors = {dataset: cmap(i) for i, dataset in zip(color_indices, institutes)}
364
364
 
365
365
  flight_ids = metadata['flight_id']
366
- for institute in tqdm(institutes, desc="Plotting", total=len(institutes), unit='institute'):
366
+ for institute in tqdm(institutes, desc="Plotting", total=len(institutes), unit='institute', disable=self._disable_tqdm):
367
367
  metadata_impl = self._db.query(institute=institute, flight_id=flight_ids, retain_query=False)
368
368
  file_paths = self._db._get_file_paths_from_metadata(metadata_impl)
369
369
  file_paths = np.unique(file_paths)
@@ -398,7 +398,7 @@ class Plotting:
398
398
 
399
399
 
400
400
  all_dfs = []
401
- for ds, _ in tqdm(self._db.data_generator(metadata, downscale_factor=downscale_factor), desc="Plotting", total=total_traces, unit='trace'):
401
+ for ds, _ in tqdm(self._db.data_generator(metadata, downscale_factor=downscale_factor, disable_tqdm=True), desc="Plotting", total=total_traces, unit='trace', disable=self._disable_tqdm):
402
402
  all_dfs.append(ds)
403
403
  df = pd.concat(all_dfs)
404
404
 
@@ -474,6 +474,7 @@ class Plotting:
474
474
 
475
475
  elif var in ['IRH_DEPTH', 'IRH_FRAC_DEPTH']:
476
476
  if var == 'IRH_DEPTH':
477
+ label = f'IRH Depth [m]'
477
478
  if cmap == None:
478
479
  cmap = cmaps.torch_r
479
480
  extend = 'both'
@@ -556,7 +557,7 @@ class Plotting:
556
557
 
557
558
  datasets = list(metadata['dataset'])
558
559
  flight_ids = metadata['flight_id']
559
- for flight_id in tqdm(flight_ids, desc="Plotting", total=len(flight_ids), unit='flight_id'):
560
+ for flight_id in tqdm(flight_ids, desc="Plotting", total=len(flight_ids), unit='flight_id', disable=self._disable_tqdm):
560
561
  metadata_impl = self._db.query(flight_id=flight_id, retain_query=False)
561
562
  file_paths = self._db._get_file_paths_from_metadata(metadata_impl)
562
563
  file_paths = np.unique(file_paths)
@@ -576,14 +577,14 @@ class Plotting:
576
577
  # --- Format Figure ---
577
578
  print('Formatting ...')
578
579
 
579
- x0, x1 = ax.get_xlim() if xlim == (None, None) else xlim
580
- y0, y1 = ax.get_ylim() if ylim == (None, None) else ylim
581
- x_extent = x1 - x0
582
- y_extent = y1 - y0
583
- aspect_ratio = y_extent / x_extent
584
580
  ax.set_xlim(*xlim)
585
581
  ax.set_ylim(*ylim)
586
582
  if color_by != 'transect':
583
+ x0, x1 = ax.get_xlim() if xlim == (None, None) else xlim
584
+ y0, y1 = ax.get_ylim() if ylim == (None, None) else ylim
585
+ x_extent = x1 - x0
586
+ y_extent = y1 - y0
587
+ aspect_ratio = y_extent / x_extent
587
588
  ax.set_xlabel('x [km]')
588
589
  ax.set_ylabel('y [km]')
589
590
  ax.set_aspect('equal')
@@ -616,17 +617,55 @@ class Plotting:
616
617
 
617
618
  # --- Plot IMBIE basins ---
618
619
  if basins and color_by != 'transect':
619
- basins = gpd.read_file(self._imbie_path)
620
- basins.geometry = basins.geometry.scale(xfact=0.001, yfact=0.001, origin=(0, 0))
621
- basins.plot(ax=ax, color='none', edgecolor='black', linewidth=0.5)
622
- center_coords = gpd.read_file(self._center_coords)
623
- center_coords.geometry = center_coords.geometry.scale(xfact=0.001, yfact=0.001, origin=(0, 0))
624
- center_coords['x'] = center_coords['geometry'].x
625
- center_coords['y'] = center_coords['geometry'].y
626
- for x, y, sub in zip(center_coords['x'], center_coords['y'], center_coords['Subregion']):
627
- ax.text(x, y, sub, fontsize=12, color='k', ha='center',
628
- path_effects=[path_effects.withStroke(linewidth=5, foreground=(1,1,1,0.7))]
629
- )
620
+ sf_basins = shapefile.Reader(self._imbie_path)
621
+ basin_patches = []
622
+
623
+ for shape_rec in sf_basins.shapeRecords():
624
+ shp = shape_rec.shape
625
+ pts = shp.points
626
+ parts = list(shp.parts) + [len(pts)] # add sentinel end index
627
+
628
+ # build one polygon per part
629
+ for i in range(len(parts) - 1):
630
+ start, end = parts[i], parts[i + 1]
631
+ ring = pts[start:end]
632
+
633
+ # scale coordinates
634
+ scaled = [(x * 0.001, y * 0.001) for x, y in ring]
635
+
636
+ poly = Polygon(scaled, closed=True, fill=False)
637
+ basin_patches.append(poly)
638
+
639
+ pc = PatchCollection(
640
+ basin_patches,
641
+ facecolor='none',
642
+ edgecolor='black',
643
+ linewidth=0.5,
644
+ )
645
+ ax.add_collection(pc)
646
+
647
+ # ---- CENTERS: read + scale + label ----
648
+ sf_centers = shapefile.Reader(self._center_coords)
649
+
650
+ # find the field index for "Subregion" in the DBF
651
+ fields = sf_centers.fields[1:] # first is DeletionFlag
652
+ field_names = [f[0] for f in fields]
653
+ sub_idx = field_names.index('Subregion')
654
+
655
+ for shape_rec in sf_centers.shapeRecords():
656
+ # assuming center_coords are points
657
+ x_raw, y_raw = shape_rec.shape.points[0]
658
+ x = x_raw * 0.001
659
+ y = y_raw * 0.001
660
+ sub = shape_rec.record[sub_idx]
661
+
662
+ if x0 <= x <= x1 and y0 <= y <= y1:
663
+ ax.text(
664
+ x, y, sub, fontsize=12, color='k', ha='center',
665
+ path_effects=[path_effects.withStroke(
666
+ linewidth=5, foreground=(1, 1, 1, 0.7)
667
+ )]
668
+ )
630
669
  # --- Plot ice core sites ---
631
670
  if stations and color_by != 'transect':
632
671
  site_coords = pd.read_pickle(self._site_coords_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anta_database
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: SQLite database for the AntArchitecture Community Data
5
5
  Author: Antoine Hermant
6
6
  Author-email: antoine.hermant@etik.com
@@ -20,12 +20,14 @@ License-File: LICENSE
20
20
  Requires-Dist: pandas
21
21
  Requires-Dist: geopandas
22
22
  Requires-Dist: xarray
23
+ Requires-Dist: h5netcdf
23
24
  Requires-Dist: h5py
24
25
  Requires-Dist: pyproj
25
26
  Requires-Dist: scipy
26
27
  Requires-Dist: matplotlib
27
28
  Requires-Dist: colormaps
28
29
  Requires-Dist: tqdm
30
+ Requires-Dist: pyshp
29
31
  Dynamic: license-file
30
32
 
31
33
  <h1 align="center">
@@ -1,9 +1,11 @@
1
1
  pandas
2
2
  geopandas
3
3
  xarray
4
+ h5netcdf
4
5
  h5py
5
6
  pyproj
6
7
  scipy
7
8
  matplotlib
8
9
  colormaps
9
10
  tqdm
11
+ pyshp
@@ -18,12 +18,14 @@ dependencies = [
18
18
  "pandas",
19
19
  "geopandas",
20
20
  "xarray",
21
+ "h5netcdf",
21
22
  "h5py",
22
23
  "pyproj",
23
24
  "scipy",
24
25
  "matplotlib",
25
26
  "colormaps",
26
27
  "tqdm",
28
+ "pyshp",
27
29
  ]
28
30
 
29
31
  keywords = ["isochrones", "database", "IRH", "radar"]
File without changes
File without changes
File without changes
File without changes
File without changes