Skip to content
Snippets Groups Projects
Commit e2726287 authored by Siddhant Tibrewal's avatar Siddhant Tibrewal
Browse files

fixed the py-linting and turned off alphabetical sorting of imports due to an...

fixed the py-linting and turned off alphabetical sorting of imports due to an issue with compiler version with which numpy was built
parent 0ed3bfc8
No related branches found
No related tags found
No related merge requests found
Pipeline #101315 waiting for manual action
......@@ -29,7 +29,7 @@ def _collect_groups(dataset):
yield from _collect_groups(g)
def add_height(dataset, name, positive_direction: str = "up", values: list[int] = []):
def add_height(dataset, name, positive_direction: str, values: list[int]):
for g in _collect_groups(dataset):
height = g.create_array(name, fill_value=None, dtype=np.int64, shape=(len(values),))
height[:] = np.asarray(values, dtype=np.int64)
......
......@@ -23,8 +23,9 @@ def add_coordinates(
Notes
-----
This function creates two new arrays in the dataset: `coord_names[0]` for longitude and `coord_names[1]` for latitude.
The `crs` array is also created, with its attributes set to indicate that it's a "point_cloud" coordinate reference system.
This function creates two new arrays in the dataset: `coord_names[0]` for longitude and
`coord_names[1]` for latitude. The `crs` array is also created, with its attributes set
to indicate that it's a "point_cloud" coordinate reference system.
Example: add_coordinates(dataset, [(10.2, 45.3), (20.4, 50.5)])
"""
......@@ -54,19 +55,20 @@ def add_coordinates(
def add_healpix_grid(dataset: zarr.Group, order: int):
"""
Add a HealPix grid to the specified Zarr dataset.
Parameters
----------
dataset : zarr.Group
The Zarr group where the HealPix grid will be added to the crs.
order : int
The order of the HealPix grid. This corresponds to 2^order for the NSIDE.
Notes
-----
The HealPix grid is stored as a single array named "crs" in the dataset, with the healpix_nside and healpix_order attributes set
accordingly. No values are added to it
Add a HealPix grid to the specified Zarr dataset.
Parameters
----------
dataset : zarr.Group
The Zarr group where the HealPix grid will be added to the crs.
order : int
The order of the HealPix grid. This corresponds to 2^order for the NSIDE.
Notes
-----
The HealPix grid is stored as a single array named "crs" in the dataset, with
the healpix_nside and healpix_order attributes set accordingly.
No values are added to it
"""
crs = dataset.create_array(name="crs", dtype=np.float32, shape=(1,))
crs.attrs["_ARRAY_DIMENSIONS"] = ("crs",)
......@@ -84,8 +86,9 @@ def add_healpix_hierarchy(
"""
Add a hierarchical structure to the specified Zarr dataset for a given Healpix order.
This function creates a group hierarchy with each level representing a specific resolution of the Healpix grid.
The `add_healpix_grid` function is used to create the actual grid arrays within each group.
This function creates a group hierarchy with each level representing a specific
resolution of the Healpix grid. The `add_healpix_grid` function is used to create the
actual grid arrays within each group.
Parameters
----------
......@@ -100,12 +103,15 @@ def add_healpix_hierarchy(
Notes
-----
This function sets up a hierarchical structure with each level representing a specific resolution of the Healpix grid.
The `hiopy::parent` attribute is used to link each group to its parent in the hierarchy, allowing for efficient navigation.
This function sets up a hierarchical structure with each level representing a
specific resolution of the Healpix grid. The `hiopy::parent` attribute is used
to link each group to its parent in the hierarchy, allowing for efficient navigation.
"""
for o in range(order, order - nr_of_coarsenings, -1):
zg = dataset.create_group(name=f"{prefix}{o}")
add_healpix_grid(zg, o)
if o < order:
parent_name = f"{dataset.basename}/{prefix}{o+1}" if dataset.basename is not "" else f"{prefix}{o+1}"
parent_name = (
f"{dataset.basename}/{prefix}{o+1}" if dataset.basename != "" else f"{prefix}{o+1}"
)
zg.attrs["hiopy::parent"] = parent_name
#!/usr/bin/env python3
import zarr
from coyote import (
Coyote,
ensure_enddef,
......@@ -17,13 +16,13 @@ from ._grids import def_grid, grid_id
from ._zarr_utils import get_var_group
from .loco import LocoServer
import numpy as np
import json
import zarr
import logging
from argparse import ArgumentParser
from itertools import chain, groupby
import json
import logging
import numpy as np
import zarr
def main():
......@@ -200,9 +199,7 @@ def main():
ensure_enddef()
if group_comm_rank() == 0:
for v in data_vars:
if "hiopy::yac_source" not in v.attrs:
continue
else:
if "hiopy::copy_metadata" in v.attrs:
comp, grid, field = get_source_triple(v)
md_str = get_field_metadata(comp, grid, field)
metadata = json.loads(md_str)
......@@ -213,7 +210,7 @@ def main():
# re-consolidate the newly updated metadata
for ds in args.datasets:
zarr.consolidate_metadata(ds.store)
zarr.consolidate_metadata(ds.store)
run()
......
......@@ -43,7 +43,5 @@ lint.select = [
"B",
# flake8-simplify
"SIM",
# isort
"I",
]
line-length = 100 # accomodate any libc++ motivated requirements of over 80 characters
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment