Is it possible to get a domain summary (aka bounding box) in a simpler way that the following?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 150
- Forks
- 23
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 2
Beschreibung
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}')
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie damit, die Funktion domain_summary und ihre Verwendung von dimension_coordinates(), auxiliary_coordinates(), Zellmethoden und dem serialise_data-Stub zu untersuchen. Klären Sie mit den Projektbetreuern den vorgesehenen Inhalt der Bounding Box und die JSON-Darstellung, bevor Sie die API ändern; abgeschlossen ist die Aufgabe, wenn es eine einfachere, abgestimmte Möglichkeit gibt, die Zusammenfassung abzurufen und zu serialisieren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- data
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100