Is it possible to get a domain summary (aka bounding box) in a simpler way that the following?
Open
Nobody has claimed this yet.
question
- Dominant language
- Python
- Stars
- 150
- Forks
- 23
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 2
Description
def domain_summary(f):
""" For a given field and it's domain, get a domain summary """
#FIXME: should be outer edge of bounds, and I am not sure about the coords and ancils, is that sufficient?
coords = [serialise(cf.Data.concatenate([b.min(), b.max()])) for b in [a.data for k,a in f.domain.dimension_coordinates().items()]]
ancils = [serialise(cf.Data.concatenate([b.min(), b.max()])) for b in [a.data for k,a in f.domain.auxiliary_coordinates().items()]]
bbox = coords+ancils
methods = get_cell_methods(f)
return bbox, methods
In doing this I'm making use of the following stub for serialising a data object, e.g. to pass to another application using json (is there a better way to do this)?
def serialise_data(o):
units = str(o.Units)
values = o.array.squeeze()
shape = o.array.shape
if len(values) == 1:
values = float(values[0])
else:
values = values.tolist()
return {'units': units, 'values': values, 'shape': shape}
def serialise(object):
methods = {
"<class 'cf.data.data.Data'>": serialise_data
}
otype = str(type(object))
if otype in methods:
return methods[otype](object)
else:
return ValueError(f'Cannot serialise {otype}')
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the domain_summary function and its use of dimension_coordinates(), auxiliary_coordinates(), cell methods, and the serialise_data stub. Clarify the intended bounding-box contents and JSON representation with the project maintainers before changing the API; done means a simpler, agreed way to obtain and serialize the summary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100