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
structis anastroschemadata structure that has a schema specification. For examplesourceis a particularastroschemastruct, that has a particularschemaspecifying its structure. -
An
entryis data in the form of astruct, i.e. an instance of astructfilled with data. -
uniquevs.distinguishing- A
uniqueattribute is one that uniquely identifies what it is referencing, one-to-one. If two things have differentuniqueattributes they are different. If they have the sameuniqueattributes, they are the same.- e.g.
bibcodeisunique, theseSources 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
distinguishingattribute is one that characterizes what it is referencing, not one-to-one. If two things have differentdistinguishingattributes, they are not necessarily different. If they have the samedistinguishingattributes, they are not necessarily the same.- e.g.
bibcodeisunique, theseSources 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
astrocatsspecific properties: [photometry,quantity,source,spectrum]. -
pyastroschema/-
[1] Using the
defs.jsonfile now, and relative paths in schema references, requires validators to usejsonschema.RefResolverobjects with the base path. To do this, when creatingstruct.SchemaDictinstances, the schema specification should be the absolute file-path. The methodutils.load_schema_dictnow returns the path to the schema also. The methodsutils.get_schema_odictandutils.get_list_of_schemahave been deprecated (commented out for now), to simplify what types of arguments are acceptable. -
[2] Code modified to be python2 and python3 compatible.
-
__init__.pycopy_schema_files()[NEW-FUNCTION]- Copy all, or a single, schema file to the given target directory.
-
schema.pyJSONOrderedDict- Add hooks to sort before
dumpanddumpscommands 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
extendorupdatemethods. - Simplified initialization to limit acceptable arguments (see [1]).
- Store the schema path and a constructed
jsonschema.RefResolverwhen possible (see [1]). extend()- Set the
check_conflictparameter 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.pywarn_with_traceback()[NEW-FUNCTION]- Modify the
warningsmodule 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.pyPAS_Validator()- Pass
kwargsalong so that aresolvercan be added to the validator.
- Pass
-
-
schema/- Restructure schema to reference new
defs.jsonfile. Added'id'attributes with each files name so that both relative and internal references will work; this is likely a bug in the pythonjsonschemapackage. 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
SchemaDictclass that stores schema specifications inStructclasses. Provides internal validation method.- NOTE:
SchemaDicthas not been integrated into theKeyclass yet, but it is stored to eachKeychain.
- NOTE:
-
Structsubclasses 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
SchemaDictclass.
- Basic construction unittests for the new
test_struct.py[NEW-FILE]- Basic tests for
Structclass, specifically making sure that subclass works as expected, and with newSchemaDictclass.
- Basic tests for
test_validation.py[NEW-FILE]- Tests for new
PAS_Validator()method (and customized class).
- Tests for new
-
keys.pyKey- Changed
Keyinstances to be immutable. Once they are created their attributes cannot be changed. __repr__()- Cache the result of
repron initialization to save time. Depends onKeybeing immutable.
- Cache the result of
equals()- BUG: in comparison, built-in methods could be compared which would fail, e.g.
formatmethod of str.
- BUG: in comparison, built-in methods could be compared which would fail, e.g.
- Changed
-
schema.pyJSONOrderedDict[NEW-CLASS]- This wrapper around an
OrderedDictclass to add some json methods (e.g. loading/saving to/from strings) extend()[NEW-FUNCTION]- Function that will add the elements from a second
dictinto 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
JSONOrderedDictdesigned 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,schemaandextendableas protectedpropertyvalues. - Changed to inherits from
schema.JSONOrderedDictto get the nice json-based import/export methods. construct()[NEW-METHOD]- Factory method which uses
struct.set_struct_schemato create a custom sub-class ofStructfor later instantiation.
- Factory method which uses
get_keychain()[REMOVED]- Deprecated in favor of
keychainproperty.
- Deprecated in favor of
to_json()[REMOVED]- Deprecated in favor of inherited
JSONOrderedDictmethods.
- Deprecated in favor of inherited
validate()- BUG: custom validator wasnt being used. Now calls internal
SchemaDictfor 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.pyPAS_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
valuefrom 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
sourcefrom 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__.pyPATHStest_dir()[NEW-METHOD]- Return the directory of test json files for specific schema.
-
keys.pyKeychainget_key_by_name()[NEW-METHOD]- Based on related method in astrocats.
- Get the key in this keychain based no its name.
-
struct.pyStructget_keychain()- Allow
mutableandextendablearguments to be passed through this method.
- Allow
Photometry[NEW-CLASS]- New subclass of
Structwith associatedphotometry.jsonschema.
- New subclass of
Spectrum[NEW-CLASS]- New subclass of
Structwith associatedspectrum.jsonschema.
- New subclass of
Entry[NEW-CLASS]- New subclass of
Structwith associatedentry.jsonschema.
- New subclass of
-
utils.pyget_schema_odict()[NEW-FUNCTION- Function that will return an
OrderedDictgiven 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
astrocatsPhotometryclass, 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
astrocatsconsistency.
- FIX: temporary addition of '...PREF_KINDS' parameters for
key.json- FIX: temporary changes for
astrocatscompatibility.
- FIX: temporary changes for
spectrum.json- BUG: fixed some incorrect requirements logic.
- Added more complex requirements/dependencies logic that was hardcoded into
astrocatsSpectrumclass.
-
CONVERSION.md[NEW-FILE]- File for documenting conversion procedures from
astrocatstoastroschema.
- 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
astrocatsEntryclass.
- 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.jsonschema.
- Schema specification that the properties of all other schema match the
photometry.json[NEW-FILE]- Schema specifying photometric quantities. Based on the
astrocatsPhotometryclass.
- 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
astrocatsSpectrumclass.
- 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
astrocatsconcept 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
Keyclass.
- Minor updates for changes to the
test_keychain.py- Minor updates for changes to the
KeyChainclass.
- 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
Sourcestandalone class toSource(Struct)subclass.
- Minor updates for changes to from
-
keys.pyKey- Use
jsonvalidation 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_ofmethods). Has optionalidenticalargument 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
Sourceclass has been generalized into theStructclass 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.CatDictclass. - On initialization, the class uses its corresponding schema to generate a
Keychainpopulated withKeyinstances 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
Structwhich is designed to be used for further subclassing to construct particular types of object, e.g.Source,Quantity, etc.Meta_Structis 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
Keyattributes.
- 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
Sourceobjects. - Currently: v0.4
- Schema specification for
-
pyastroschema/-
tests/test_keychain.py- Unittests for the
Keychainclass.
- Unittests for the
test_source.py- Basic tests for basic functionality of
Sourceclass. - Tests for both copy and deepcopy behavior.
- Basic tests for basic functionality of
-
__main__.pymain()- 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
Keychainfromsource.pyto here. - Added new
Keyclass to hold each property key.
- Moved
-
source.py- Removed
Keychainclass (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.pyjson_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/sourcefor checking validations. -
pyastroschema/Keychainclass to store parameter names ('keys') specified in schema files.Sourceclass to store data associated with thesource.jsonschema. Currently specific to the 'source' structure, and will be generalized in the future to arbitrary schema.- Validation works for 'source' entries and
Sourceinstances using thejsonschemapython package. This uses the example JSON files intests/source.