This package defines a set of JSON schema relevant to astronomy and astrophysics research. The schema are meant to specify the structure of JSON files used to contain astronomical (and associated) data. The package also contains modules for the use of those schema in python
, and in the future additional languages.
schema/
: the schema specifications themselvesmetaschema/
: the metaschema specifying the structure of each astro-schema
pyastroschema/
: the python module for interacting with astroschematests/
: directory containing sample JSON files for testing schema validationastroschema.json
: description of each schema included in this package.
-
A
struct
is anastroschema
data structure that has a schema specification. For examplesource
is a particularastroschema
struct
, that has a particularschema
specifying its structure. -
An
entry
is data in the form of astruct
, i.e. an instance of astruct
filled with data. -
unique
vs.distinguishing
- A
unique
attribute is one that uniquely identifies what it is referencing, one-to-one. If two things have differentunique
attributes they are different. If they have the sameunique
attributes, they are the same.- e.g.
bibcode
isunique
, theseSource
s are the same:{"name": "Open Supernova Catalog", "bibcode": "2017ApJ...835...64G", "alias": 0}
{"name": "Guillochon+2017", "bibcode": "2017ApJ...835...64G", "alias": 1}
- e.g.
- A
distinguishing
attribute is one that characterizes what it is referencing, not one-to-one. If two things have differentdistinguishing
attributes, they are not necessarily different. If they have the samedistinguishing
attributes, they are not necessarily the same.- e.g.
bibcode
isunique
, theseSource
s are the same:{"name": "Open Supernova Catalog", "bibcode": "2017ApJ...835...64G", "alias": 0}
{"name": "Guillochon+2017", "bibcode": "2017ApJ...835...64G", "alias": 1}
- e.g.
- A
-
Modified numerous schema to remove
astrocats
specific properties: [photometry
,quantity
,source
,spectrum
]. -
pyastroschema/
-
[1] Using the
defs.json
file now, and relative paths in schema references, requires validators to usejsonschema.RefResolver
objects with the base path. To do this, when creatingstruct.SchemaDict
instances, the schema specification should be the absolute file-path. The methodutils.load_schema_dict
now returns the path to the schema also. The methodsutils.get_schema_odict
andutils.get_list_of_schema
have been deprecated (commented out for now), to simplify what types of arguments are acceptable. -
[2] Code modified to be python2 and python3 compatible.
-
__init__.py
copy_schema_files()
[NEW-FUNCTION]- Copy all, or a single, schema file to the given target directory.
-
schema.py
JSONOrderedDict
- Add hooks to sort before
dump
anddumps
commands by passing sorting function.
- Add hooks to sort before
SchemaDict
- No longer accepts a list of schema as argument. Schema must be combined using either
extend
orupdate
methods. - Simplified initialization to limit acceptable arguments (see [1]).
- Store the schema path and a constructed
jsonschema.RefResolver
when possible (see [1]). extend()
- Set the
check_conflict
parameter to True by default.
- Set the
update()
[NEW-FUNCTION]- Added wrapper around
JSONOrderedDict.update()
to first convert argument toSchemaDict
.
- Added wrapper around
- No longer accepts a list of schema as argument. Schema must be combined using either
-
utils.py
warn_with_traceback()
[NEW-FUNCTION]- Modify the
warnings
module to provide tracebacks
- Modify the
get_schema_odict()
[REMOVED]- See [1]
get_list_of_schema()
[REMOVED]- See [1]
index_entry_for_schema()
[NEW-FUNCTION]- Retrieve the index entry (dict) for the target schema.
path_for_schema_file()
[NEW-FUNCTION]- Retrieve the full-path for the target schema.
-
validation.py
PAS_Validator()
- Pass
kwargs
along so that aresolver
can be added to the validator.
- Pass
-
-
schema/
- Restructure schema to reference new
defs.json
file. Added'id'
attributes with each files name so that both relative and internal references will work; this is likely a bug in the pythonjsonschema
package. entry.json
- Removed astrocats specific fields.
defs.json
[NEW-FILE]- New file specifically for schema definitions, references from other schema files.
- Restructure schema to reference new
-
astroschema_index.json
- Updated to include new
defs.json
.
- Updated to include new
-
LICENSE
- Changed from MIT to GNU
-
MANIFEST.in
,requirements.in
,requirements.txt
,setup.py
,tox.ini
- Added package material for distribution.
-
Add new 'format' schema specifications including 'numeric' and 'astrotime'.
-
New
SchemaDict
class that stores schema specifications inStruct
classes. Provides internal validation method.- NOTE:
SchemaDict
has not been integrated into theKey
class yet, but it is stored to eachKeychain
.
- NOTE:
-
Struct
subclasses have been upgraded to use protected class-attributes (i.e. shared) to store schema information. A wrapper (struct.set_struct_schema()
) and class factor method (struct.Struct.construct()
) have been added to provide a customization API for derived classes. -
pyastroschema/
-
tests/
test_schemadict.py
[NEW-FILE]- Basic construction unittests for the new
SchemaDict
class.
- Basic construction unittests for the new
test_struct.py
[NEW-FILE]- Basic tests for
Struct
class, specifically making sure that subclass works as expected, and with newSchemaDict
class.
- Basic tests for
test_validation.py
[NEW-FILE]- Tests for new
PAS_Validator()
method (and customized class).
- Tests for new
-
keys.py
Key
- Changed
Key
instances to be immutable. Once they are created their attributes cannot be changed. __repr__()
- Cache the result of
repr
on initialization to save time. Depends onKey
being immutable.
- Cache the result of
equals()
- BUG: in comparison, built-in methods could be compared which would fail, e.g.
format
method of str.
- BUG: in comparison, built-in methods could be compared which would fail, e.g.
- Changed
-
schema.py
JSONOrderedDict
[NEW-CLASS]- This wrapper around an
OrderedDict
class to add some json methods (e.g. loading/saving to/from strings) extend()
[NEW-FUNCTION]- Function that will add the elements from a second
dict
into the first, without overwriting existing parameters (likeupdate()
does).
- Function that will add the elements from a second
- This wrapper around an
SchemaDict
[NEW-CLASS]- Subclass of
JSONOrderedDict
designed to contain schema. Adds validation methods. Can be initialized from numerous schema, in which caseextend()
is used to combine them.
- Subclass of
-
struct.py
- All of the derived structures (subclasses of
Struct
) now use the decorator instead of subclassing withMeta_Struct
. Struct
- Added
keychain
,schema
andextendable
as protectedproperty
values. - Changed to inherits from
schema.JSONOrderedDict
to get the nice json-based import/export methods. construct()
[NEW-METHOD]- Factory method which uses
struct.set_struct_schema
to create a custom sub-class ofStruct
for later instantiation.
- Factory method which uses
get_keychain()
[REMOVED]- Deprecated in favor of
keychain
property
.
- Deprecated in favor of
to_json()
[REMOVED]- Deprecated in favor of inherited
JSONOrderedDict
methods.
- Deprecated in favor of inherited
validate()
- BUG: custom validator wasnt being used. Now calls internal
SchemaDict
for validation.
- BUG: custom validator wasnt being used. Now calls internal
- Added
Meta_Struct
[REMOVED]- Deprecated in favor of new subclassing procedures.
- All of the derived structures (subclasses of
-
validation.py
PAS_Validator()
<==Default_Validator()
- New customized validator that not only sets defaults (as before) but also checks the
"numeric"
'format' specifier. - Tests added for behavior.
- New customized validator that not only sets defaults (as before) but also checks the
-
-
schema/
quantity.json
- BUG, FIX: Changed
value
from being numeric to being any-type. This is to accommodate 'alias' values inastrocats
... not sure if this should remain or be changed. - BUG, FIX: Changed
source
from being numeric to being any-type. This is to accommodate strings like"1,3,4"
currently used in astrocats. This should be fixed in the future.
- BUG, FIX: Changed
-
FIX: Numerous aspects of the structure schema changed (e.g. variable names, new parameters) for consistency with
astrocats
. This is temporary. These should all be restored back / removed later. -
pyastroschema
-
tests/
test_photometry.py
[NEW-FILE]- Unittests for the 'photometry' schema and class.
- Include tests for some of the complex 'dependencies' and requirements in the schema.
test_spectrum.py
[NEW-FILE]- Unittests for the 'spectrum' schema and class.
- Include tests for some of the complex dependencies and requirements in the schema.
-
__init__.py
PATHS
test_dir()
[NEW-METHOD]- Return the directory of test json files for specific schema.
-
keys.py
Keychain
get_key_by_name()
[NEW-METHOD]- Based on related method in astrocats.
- Get the key in this keychain based no its name.
-
struct.py
Struct
get_keychain()
- Allow
mutable
andextendable
arguments to be passed through this method.
- Allow
Photometry
[NEW-CLASS]- New subclass of
Struct
with associatedphotometry.json
schema.
- New subclass of
Spectrum
[NEW-CLASS]- New subclass of
Struct
with associatedspectrum.json
schema.
- New subclass of
Entry
[NEW-CLASS]- New subclass of
Struct
with associatedentry.json
schema.
- New subclass of
-
utils.py
get_schema_odict()
[NEW-FUNCTION- Function that will return an
OrderedDict
given a filename, indexed schema-name, or odict.
- Function that will return an
get_list_of_schema()
[NEW-FUNCTION]- Returns a list of odict schema given one or more specified by filename, str, or odict.
-
-
schema/
photometry.json
- Added dependencies which were coded manually into
astrocats
Photometry
class, for example requiring frequency, band or energy when flux is included.
- Added dependencies which were coded manually into
entry.json
- FIX: temporary addition of '...PREF_KINDS' parameters for
astrocats
consistency.
- FIX: temporary addition of '...PREF_KINDS' parameters for
key.json
- FIX: temporary changes for
astrocats
compatibility.
- FIX: temporary changes for
spectrum.json
- BUG: fixed some incorrect requirements logic.
- Added more complex requirements/dependencies logic that was hardcoded into
astrocats
Spectrum
class.
-
CONVERSION.md
[NEW-FILE]- File for documenting conversion procedures from
astrocats
toastroschema
.
- File for documenting conversion procedures from
-
README.md
- Lots of new 'to-do' items and issues that need to be addressed.
-
schema/
entry.json
[NEW-FILE]- Specifications for a catalog entry (names, sources, quantities, etc). Based on the
astrocats
Entry
class.
- Specifications for a catalog entry (names, sources, quantities, etc). Based on the
key.json
[NEW-FILE]- Schema specification for individual 'keys' of general astroschema schema. Used with
meta-schema.json
.
- Schema specification for individual 'keys' of general astroschema schema. Used with
meta-schema.json
<==meta-schema/astro-schema_draft-0.json
- Schema specification that the properties of all other schema match the
key.json
schema.
- Schema specification that the properties of all other schema match the
photometry.json
[NEW-FILE]- Schema specifying photometric quantities. Based on the
astrocats
Photometry
class.
- Schema specifying photometric quantities. Based on the
quantity.json
[NEW-FILE]- Schema specifying core 'quantities' which are the data points for entries and composite data values (e.g.
photometry
).
- Schema specifying core 'quantities' which are the data points for entries and composite data values (e.g.
spectrum.json
[NEW-FILE]- Schema specifying spectrum quantities. Based on the
astrocats
Spectrum
class.
- Schema specifying spectrum quantities. Based on the
source.json
- Use both a 'unique' and 'distinguishing' attributes. A 'unique' attribute is one that uniquely defines what it is referring to (i.e. if two 'unique' attributes match, then these are referring to the same object). A 'distinguishing' attribute is one that can be used to compare two instances (based on the
astrocats
concept of 'comparable' values). If two 'distinguishing' values are different, then the objects are different; if they are the same, the objects may be the same.
- Use both a 'unique' and 'distinguishing' attributes. A 'unique' attribute is one that uniquely defines what it is referring to (i.e. if two 'unique' attributes match, then these are referring to the same object). A 'distinguishing' attribute is one that can be used to compare two instances (based on the
-
pyastroschema/
-
tests/
test_entry.py
[NEW-FILE]- Simplest tests on the new 'entry' schema.
test_key.py
- Minor updates for changes to the
Key
class.
- Minor updates for changes to the
test_keychain.py
- Minor updates for changes to the
KeyChain
class.
- Minor updates for changes to the
test_quantity.py
[NEW-FILE]- Basic testing of new 'quantity' schema.
test_source.py
- Minor updates for changes to from
Source
standalone class toSource(Struct)
subclass.
- Minor updates for changes to from
-
keys.py
Key
- Use
json
validation instead of manual checking (e.g. of requirements). validate()
[NEW-METHOD]- Load a custom validator that not only validates but sets default values. See
validation.py
.
- Load a custom validator that not only validates but sets default values. See
equals()
[NEW-METHOD]- Compare two keys each-other (analogous to astrocats
is_duplicate_of
methods). Has optionalidentical
argument to determine precision of comparison.
- Compare two keys each-other (analogous to astrocats
- Use
-
schema.py
[NEW-FILE]- Beginning of class to represent schema themselves.
- NOTE: non-operational.
-
struct.py
<==source.py
- What was previously the
Source
class has been generalized into theStruct
class which can then be used for any data-structured. Struct
[NEW-CLASS]- Generalized class structure to apply to any catalog-object that is schema-specified. This is analogous (and largely based on) the
astrocats.catdict.CatDict
class. - On initialization, the class uses its corresponding schema to generate a
Keychain
populated withKey
instances that describe each property of this class. Validation is performed using jsonschema.
- Generalized class structure to apply to any catalog-object that is schema-specified. This is analogous (and largely based on) the
Meta_Struct
[NEW-CLASS]- Subclass of
Struct
which is designed to be used for further subclassing to construct particular types of object, e.g.Source
,Quantity
, etc.Meta_Struct
is used as the method to specify the schema describing/constraining the particular structure.
- Subclass of
- What was previously the
-
validation.py
[NEW-FILE]- Create a jsonschema validator instance with extended functionality to set default values of parameters. Currently used to set default
Key
attributes.
- Create a jsonschema validator instance with extended functionality to set default values of parameters. Currently used to set default
-
-
schema/
meta-schema/
astro-schema_draft-0.json
[NEW-FILE]- First version of a astro-schema specific meta-schema for validating all astro-schema schema. Currently this takes the standard json-schema and extends it slightly: required the 'type' and 'unique' attributes for each 'property'.
source.json
- Schema specification for
Source
objects. - Currently: v0.4
- Schema specification for
-
pyastroschema/
-
tests/
test_keychain.py
- Unittests for the
Keychain
class.
- Unittests for the
test_source.py
- Basic tests for basic functionality of
Source
class. - Tests for both copy and deepcopy behavior.
- Basic tests for basic functionality of
-
__main__.py
main()
- This is the primary interface routine.
- Loads the astro-schema metaschema and validates it against the standard json-schema.
- Loads all astro-schema and validates them against both the meta-schema and the standard json-schema.
- Produces an 'index' output file listing the current included schema, and their version and modification information.
-
keys.py
- Moved
Keychain
fromsource.py
to here. - Added new
Key
class to hold each property key.
- Moved
-
source.py
- Removed
Keychain
class (seekeys.py
). Source
- Added overriding of
__copy__
and__deepcopy__
methods. is_duplicate_of()
[new-function]- Duplicated behavior of related method in astrocats class.
- Added overriding of
- Removed
-
utils.py
json_load_str()
[new-function]- Load dictionary from json-formatted string.
get_relative_path()
[new-function]- Convert from a full path to a path relative to a given reference path.
-
-
Simple schema for 'source' structures created.
-
A few test JSON files added in
tests/source
for checking validations. -
pyastroschema/
Keychain
class to store parameter names ('keys') specified in schema files.Source
class to store data associated with thesource.json
schema. Currently specific to the 'source' structure, and will be generalized in the future to arbitrary schema.- Validation works for 'source' entries and
Source
instances using thejsonschema
python package. This uses the example JSON files intests/source
.