-
-
Notifications
You must be signed in to change notification settings - Fork 124
/
extension.py
48 lines (39 loc) · 1.23 KB
/
extension.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Defines extension that is used by ASDF for recognizing specutils types
"""
import os
from asdf.util import filepath_to_url
from asdf.extension import AsdfExtension
from astropy.io.misc.asdf.extension import ASTROPY_SCHEMA_URI_BASE
from .tags.spectra import *
from .types import _specutils_types
SCHEMA_PATH = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'schemas'))
SPECUTILS_URL_MAPPING = [
(ASTROPY_SCHEMA_URI_BASE,
filepath_to_url(
os.path.join(SCHEMA_PATH, 'astropy.org')) +
'/{url_suffix}.yaml')]
class SpecutilsExtension(AsdfExtension):
"""
Defines specutils types and schema locations to be used by ASDF
"""
@property
def types(self):
"""
Collection of tag types that are used by ASDF for serialization
"""
return _specutils_types
@property
def tag_mapping(self):
"""
Defines mapping of specutils tag URIs to URLs
"""
return [('tag:astropy.org:specutils',
ASTROPY_SCHEMA_URI_BASE + 'specutils{tag_suffix}')]
@property
def url_mapping(self):
"""
Defines mapping of specutils schema URLs into real locations on disk
"""
return SPECUTILS_URL_MAPPING