GithubHelp home page GithubHelp logo

rama's People

Contributors

mcdittmar avatar olaurino avatar tomdonaldson avatar

Watchers

 avatar

rama's Issues

CONSTANT/LITERAL under TEMPLATES context

Within the TEMPLATES context, these elements do not produce a constant, repeating value per row, but only a single scalar value.
eg: SkyCoord.longitude => => Quantity with array value (one per row)
SkyCoord.latitude => => Quantity with singular value

def parse_literal(context, xml_element):
value = xml_element.xpath(VALUE_ATTR)[0]
value_type = xml_element.xpath(TYPE_ATTR)[0]
units = xml_element.xpath(UNIT_ATTR)
unit = units[0] if units else None
return context.get_type_by_id(value_type)(value, unit)
def parse_constant(context, xml_element):
param_ref = xml_element.xpath(REF_ATTR)[0]
find_param_xpath = f"//{PARAM}[{ID_ATTR}='{param_ref}']"
param_elements = xml_element.xpath(find_param_xpath)
if not param_elements:
msg = f"Can't find param with ID {param_ref}. Setting value to NaN"
LOG.warning(msg)
warnings.warn(msg, SyntaxWarning)
return numpy.NaN
param_element = param_elements[0]
value_type = xml_element.xpath(TYPE_ATTR)[0]
value = param_element.xpath(VALUE_ATTR)[0]
units = param_element.xpath(UNIT_ATTR)
unit = units[0] if units else None
return context.get_type_by_id(value_type)(value, unit)

VOTable handling for RA,DEC in sexagesimal notation

I believe its because the annotated dmtype is RealQuantity, but if the VOTable contains string columns of RA,DEC in sexagesimal notation, the TABLEDATA handler, I think, attempts to make numeric columns from them, and fails miserably.
TypeError, "The value must be a valid Python or Numpy numeric value"

Not sure what to do about this, but probably should be able to handle this notation in Positional columns.

SkyCoord adapter: Exception if no lon,lat values on Point

The SkyCoord adapter operates on the coords:Point class
Point

  • axis1
  • axis2
  • axis3
    And has logic for handling Spherical and Cartesian representations.

A nasty exception ensues if axis1 and/or axis2 have no value.
The SkyCoord instructor complains that they are not proper value types.

Another point to consider here.
Point used in Velocity context, underlying Point is still cast to a SkyCoord, but that is not really appropriate.
NOTE: SkyCoord contains position, velocity, proper motion, radial velocity together in the same Frame.

Multi-dimensional COLUMN handling

Need to check the response for a column whose value has multiplicity > 1 (ie: an array).
See test_reader.py::test_parsing_columns()

  • MultiObj.b is an array element of type ivoa:real[2]
    o for CONSTANT and LITERAL, this results in 'list of float', [ r1, r2 ]
    o for COLUMN, this results in 'list of length 1 of MaskedColumn'

  • MultiObj.a (scalar)
    o LITERAL - float n/a v1
    o CONSTANT - float n/a v1
    o COLUMN - MaskedColumn(float) shape(2,) [r1v1, r2v1]

  • MultiObj.b (array)
    o LITERAL - list(float) len=2 [v1, v2]
    o CONSTANT - list(float) len=2 [v1, v2]
    o COLUMN - list(MaskedColumn(float)) len=1 <<< This doesn't look right
    list[0] = MaskedColumn shape(2,2) [[r1v1, r1v2],[r2v1, r2v2]]

  • Handled by: framework.VodmlDescriptor::select_return_value()
    o this is the base class for Attribute, Reference, Composition
    o current logic looks OK for Reference and Composition, but not Attribute
    o probably want override in Attribute
    Composition max = -1 for unbound (so if not making override, take into account)

def test_parsing_columns( columns_file ):
"""
Test parsing of COLUMN elements
<COLUMN dmtype ref >
<OPTIONMAPPING>
<OPTION>"string"</OPTION>
<ENUMLITERAL>"vodml-id"</ENUMLITERAL> or <SEMANTICCONCEPT>
</OPTIONMAPPING>
</COLUMN>
The parser pushes the Table rows into value arrays

RFE add support for REMOTEREFERENCE

I have a VOTable with a REMOTEREFERENCE, but this is not interpreted by the rama code.
Following is snippet of VOTable annotation containing a REMOTEREFERENCE.

       <TEMPLATES tableref="T1622026678915_1">
            <INSTANCE dmtype="sample:catalog.Source" ID="T1622026678915_718">
                <PRIMARYKEY>
                    <PKFIELD>
                        <COLUMN dmtype="ivoa:string" ref="oidsaada_100"/>
                    </PKFIELD>
                </PRIMARYKEY>
                <ATTRIBUTE dmrole="sample:catalog.AbstractSource.position">
                    <INSTANCE dmtype="sample:catalog.SkyCoordinate">
                        <ATTRIBUTE dmrole="sample:catalog.SkyCoordinate.longitude">
                            <COLUMN dmtype="ivoa:RealQuantity" ref="pos_ra_csa_102"/>
                        </ATTRIBUTE>
                        <ATTRIBUTE dmrole="sample:catalog.SkyCoordinate.latitude">
                            <COLUMN dmtype="ivoa:RealQuantity" ref="pos_dec_csa_103"/>
                        </ATTRIBUTE>
                        <REFERENCE dmrole="sample:catalog.SkyCoordinate.frame">
                            <REMOTEREFERENCE>http://ivoa.net/dm-instances/STC/Coords/ICRS-frame.xml</REMOTEREFERENCE>
                        </REFERENCE>
                    </INSTANCE>
                </ATTRIBUTE>
                <ATTRIBUTE dmrole="sample:catalog.AbstractSource.positionError">
                    <INSTANCE dmtype="sample:catalog.GenericEllipse">
                        <ATTRIBUTE dmrole="sample:catalog.GenericEllipse.major">
                            <COLUMN dmtype="ivoa:real" ref="error_maj_csa_105"/>

The rama code generates a position as follows:
'position': {'rama.models.test.sample.SkyCoordinate': {'frame': None, 'latitude': -17.071667101891, 'longitude': 340.91055060369}},

Inconsistent interface for data access

The path to the 'leaf' data from columns appears to depend on what sort of value is at the leaf:
Or maybe more to the point, how it is serialized.

  • if has 'unit'(?):
    • see warnings from astropy/table.py:
      • "UserWarning: dropping mask in Quantity column '_color': masked Quantity not supported"
    • column values type is "astropy.units.quantity.Quantity
      • access data via: prop.measure.coord.hardness_ratio.value[row] == float64
      • access data via: prop.measure.coord.hardness_ratio[row] == Quantity
  • otherwise:
    • column values type is "astropy.table.column.MaskedColumn"
      • access data via: prop.measure.coord.hardness_ratio[row] == float64

dmusecases:standard_properties

  • gaia - color is a difference in magnitudes, so has unit='mag'
  • 4xmm - hardness ratio is dimensionless, so no units.

Base types have mixed ability to store the common 'name' from the serialization

The Quantity types are mapped to astropy.units.Quantity, on which you can add a 'name' attribute.
The others, map to base types (float, int, bool), which can not be modified/appended with a 'name'.

Use Case:
* Not sure there is a use case, but noting the disparity in the code.
* The current usage (cube.py) is that column names from FIELD element are used
as the key in a hash storing the column values (Quantity, or MaskedColumn? instance).
However, in this context as Measurements, the columns map to the
corresponding Axes of the coordinate space, and the name should
map back to the meas.coord.coordsys.coordspace.axis[n].name
** This is something to explore more thoroughly **
o perhaps coords/meas needs shortcut methods to access coordspace info.
o should meas implementation collapse coords?? making access to content at the meas level?

@VO("ivoa:integer")
class VOInteger:
def __new__(cls, value, _):
return int(value)
@VO("ivoa:nonnegativeInteger")
class VONonNegativeInteger:
def __new__(cls, value, _):
value = int(value)
if value < 0:
raise ValueError(f"Value must be positive: {value}")
return value
@VO("ivoa:real")
class VOReal:
def __new__(cls, value, _):
return float(value)
@VO("ivoa:datetime")
class VODateTime:
"""
Handled as a Python datetime instance.
"""
def __new__(cls, value, _):
return parser.parse(value)
@VO("ivoa:IntegerQuantity")
class IntegerQuantity:
"""
Handled by AstroPy Quantity.
NOTE: The value is converted to floating point..
"""
def __new__(cls, value, unit):
value = int(value)
try:
quantity = value * u.Unit(unit)
except (ValueError, TypeError):
quantity = value * u.dimensionless_unscaled
return quantity
@VO("ivoa:RealQuantity")
class RealQuantity:
"""
Handled by AstroPy Quantity.
"""
def __new__(cls, value, unit):
value = float(value)
try:
quantity = value * u.Unit(unit)
except (ValueError, TypeError):
quantity = value * u.dimensionless_unscaled
return quantity

RFE add support for PRIMARYKEY

The following VOTable annotation segment declares a PRIMARYKEY. In the Source instance created by rama this is left out.
PRIMARYKEY is very important to distinguish ObjectType instances, particularly in certain flattened situations or ORM FK->PK mapping:

  <TEMPLATES tableref="T1622026678915_1">
         <INSTANCE dmtype="sample:catalog.Source" ID="T1622026678915_718">
             <PRIMARYKEY>
                 <PKFIELD>
                     <COLUMN dmtype="ivoa:string" ref="oidsaada_100"/>
                 </PKFIELD>
             </PRIMARYKEY>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.