Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for gwcs 0.14 and ndcube 2 beta #86

Merged
merged 7 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions .circleci/config.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .circleci/early_exit.sh

This file was deleted.

15 changes: 8 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
build:
image: latest

requirements_file: requirements.txt
version: 2

python:
version: 3.6
pip_install: false
setup_py_install: true
version: 3.8
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra_requirements:
- docs
1 change: 1 addition & 0 deletions changelog/86.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support gwcs 0.14 and ndcube 2.0.0b1
31 changes: 1 addition & 30 deletions dkist/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import asdf
import astropy.table
import gwcs
from astropy.visualization.wcsaxes import WCSAxes
from astropy.wcs.wcsapi import SlicedLowLevelWCS
from astropy.wcs.wcsapi.wrappers import SlicedLowLevelWCS
from ndcube.ndcube import NDCube

from dkist.io import DaskFITSArrayContainer
Expand Down Expand Up @@ -93,28 +92,6 @@ def __init__(self, data, wcs, uncertainty=None, mask=None, meta=None,
self._header_table = headers
self._array_container = None

"""
Changes to the NDCube APIs.
"""

# Overload this to only expose the new API in this package, this can be
# removed once NDCube 2 is finalised.
def crop_by_coords(self, lower_corner, upper_corner, units=None):
return super().crop_by_coords(lower_corner, upper_corner=upper_corner, units=units)

@property
def world_axis_physical_types(self):
"""
Returns an iterable of strings describing the physical type for each world axis.

The strings conform to the International Virtual Observatory Alliance
standard, UCD1+ controlled Vocabulary. For a description of the standard and
definitions of the different strings and string components,
see http://www.ivoa.net/documents/latest/UCDlist.html.

"""
return self.wcs.world_axis_physical_types[::-1]

"""
Properties.
"""
Expand Down Expand Up @@ -201,12 +178,6 @@ def __repr__(self):
def __str__(self):
return dataset_info_str(self)

def _as_mpl_axes(self):
"""
Allow this object to be passed to matplotlib as a projection.
"""
return WCSAxes, {'transform': self.wcs}

"""
DKIST specific methods.
"""
Expand Down
40 changes: 5 additions & 35 deletions dkist/dataset/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pathlib import Path

import dask.array as da
import numpy as np
import pytest

import asdf
Expand Down Expand Up @@ -38,15 +37,15 @@ def test_repr(dataset, dataset_3d):

def test_wcs_roundtrip(dataset):
p = (10*u.pixel, 10*u.pixel)
w = dataset.pixel_to_world(*p)
p2 = dataset.world_to_pixel(w)
assert_quantity_allclose(p, p2)
w = dataset.wcs.pixel_to_world(*p)
p2 = dataset.wcs.world_to_pixel(w)
assert_quantity_allclose(p, p2 * u.pix)


def test_wcs_roundtrip_3d(dataset_3d):
p = (10*u.pixel, 10*u.pixel, 10*u.pixel)
w = dataset_3d.pixel_to_world(*p)
p2 = dataset_3d.world_to_pixel(*w)
w = dataset_3d.wcs.pixel_to_world(*p)
p2 = dataset_3d.wcs.world_to_pixel(*w) * u.pix
assert_quantity_allclose(p[:2], p2[:2])
assert_quantity_allclose(p[2], p2[2])

Expand Down Expand Up @@ -100,35 +99,6 @@ def test_no_filenames(dataset_3d):
assert dataset_3d.filenames == []


def test_crop_by_coords(dataset_3d):
arr = dataset_3d.crop_by_coords((5*u.nm, 5*u.arcsec, 5*u.arcsec),
(9*u.nm, 9*u.arcsec, 9*u.arcsec))

da_crop = dataset_3d.data[5:10, 5:10, 5:10]
assert arr.data.shape == da_crop.shape
assert np.allclose(arr.data, da_crop)


def test_crop_by_coords_units(dataset_3d):
arr = dataset_3d.crop_by_coords((5, 5, 5),
(9, 9, 9),
(u.nm, u.arcsec, u.arcsec))

da_crop = dataset_3d.data[5:10, 5:10, 5:10]
assert arr.data.shape == da_crop.shape
assert np.allclose(arr.data, da_crop)


def test_crop_by_coords_bad_args(dataset_3d):
with pytest.raises(ValueError):
dataset_3d.crop_by_coords((5, 5)*u.arcsec, (5, 5))


def test_crop_by_coords_bad_units(dataset_3d):
with pytest.raises(ValueError):
dataset_3d.crop_by_coords((5, 5, 5), (9, 9, 9), units=(u.pix, u.pix))


def test_download(mocker, dataset):
mocker.patch("dkist.dataset.dataset.watch_transfer_progress",
autospec=True)
Expand Down
14 changes: 7 additions & 7 deletions dkist/io/asdf/schemas/dkist.nso.edu/dkist/dataset-0.1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ description:
type: object
properties:
data:
$ref: "tag:dkist.nso.edu:dkist/array_container-0.2.0"
$ref: "http://dkist.nso.edu/schemas/dkist/array_container-0.2.0"

wcs:
description: The coordinate system for the complete dataset.
$ref: "tag:stsci.edu:gwcs/wcs-1.0.0"
$ref: "http://stsci.edu/schemas/gwcs/wcs-1.0.0"

headers:
description: A table of all the headers for the constituent files.
anyOf:
- $ref: "tag:stsci.edu:asdf/core/table-1.0.0"
- $ref: "tag:astropy.org:astropy/table/table-1.0.0"
- $ref: "http://stsci.edu/schemas/asdf/core/table-1.0.0"
- $ref: "http://astropy.org/schemas/astropy/table/table-1.0.0"

meta:
description: Dataset metadata, describing the whole dataset.
type: object

mask:
$ref: "tag:stsci.edu:asdf/core/ndarray-1.0.0"
$ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0"

unit:
$ref: "tag:stsci.edu:asdf/unit/unit-1.0.0"
$ref: "http://stsci.edu/schemas/asdf/unit/unit-1.0.0"

required: [data, headers, wcs]
allowAdditionalProperties: true
additionalProperties: true
...
41 changes: 41 additions & 0 deletions dkist/io/asdf/schemas/dkist.nso.edu/dkist/dataset-0.2.0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%YAML 1.1
---
$schema: "http://stsci.edu/schemas/yaml-schema/draft-01"
id: "http://dkist.nso.edu/schemas/dkist/dataset-0.2.0"
tag: "tag:dkist.nso.edu:dkist/dataset-0.2.0"

title: |
A DKIST Level 1 Dataset object.
description:
The container for a distributed dataset object.

type: object
properties:
data:
$ref: "http://dkist.nso.edu/schemas/dkist/array_container-0.2.0"

wcs:
description: The coordinate system for the complete dataset.
anyOf:
- $ref: "http://stsci.edu/schemas/gwcs/wcs-1.0.0"
- $ref: "http://stsci.edu/schemas/gwcs/wcs-1.1.0"

headers:
description: A table of all the headers for the constituent files.
anyOf:
- $ref: "http://stsci.edu/schemas/asdf/core/table-1.0.0"
- $ref: "http://astropy.org/schemas/astropy/table/table-1.0.0"

meta:
description: Dataset metadata, describing the whole dataset.
type: object

mask:
$ref: "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0"

unit:
$ref: "http://stsci.edu/schemas/asdf/unit/unit-1.0.0"

required: [data, headers, wcs]
additionalProperties: true
...
2 changes: 1 addition & 1 deletion dkist/io/asdf/tags/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DatasetType(DKISTType):
name = "dataset"
types = ['dkist.dataset.Dataset']
requires = ['dkist']
version = "0.1.0"
versions = ["0.1.0", "0.2.0"]

@classmethod
def from_tree(cls, node, ctx):
Expand Down
4 changes: 3 additions & 1 deletion dkist/io/level_1_dataset_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ tag: "tag:stsci.edu:asdf/core/asdf-1.1.0"
type: object
properties:
dataset:
$ref: "tag:dkist.nso.edu:dkist/dataset-0.1.0"
anyOf:
- $ref: "http://dkist.nso.edu/schemas/dkist/dataset-0.1.0"
- $ref: "http://dkist.nso.edu/schemas/dkist/dataset-0.2.0"

required: [dataset]
additionalProperties: true
2 changes: 0 additions & 2 deletions dkist/net/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ def test_append_query_response(empty_query_response, example_api_response):
assert isinstance(qr.blocks, list)
assert qr.blocks == list(qr.table.iterrows())

assert DKISTQueryReponse.from_results(example_api_response["searchResults"]) == qr


def test_length_0_qr(empty_query_response):
assert len(empty_query_response) == 0
Expand Down
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# git deps for read the docs
git+https://github.com/sunpy/ndcube
22 changes: 0 additions & 22 deletions requirements.txt

This file was deleted.

8 changes: 4 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ install_requires =
globus-sdk
appdirs
parfive[ftp]
astropy>=4.0
astropy
asdf
gwcs>=0.12
sunpy[net,asdf]>=2.0rc2
ndcube>=2.0dev186
gwcs
sunpy[net,asdf]>=2.0
ndcube>=2.0.0b2
setup_requires = setuptools_scm

[options.extras_require]
Expand Down