dr-rodriguez / DSII_LocalGroupDB

The Local Group Galaxy Database
4 stars 2 forks source link

Make it possible to add measurements (instead of replacing) via second file for the same object #22

Open eteq opened 4 years ago

eteq commented 4 years ago

This is motivated by the attempt to add a new measurement in this commit: https://github.com/eteq/DSII_LocalGroupDB/commit/8cd1d47a77af0e412df01edf1581bd6d3b4dfc0c

I thought that would yield a second measurement option for the Boo (I) object, i.e. resulting in the same things as this commit: https://github.com/dr-rodriguez/DSII_LocalGroupDB/commit/fa58ef7bc3be00ac936ef7f8d1d9ddbb7cfddb1b . But it doesn't - the new measurement replaces the old one instead of adding it to the list. That's not ideal because I think the use case illustrated in https://github.com/dr-rodriguez/DSII_LocalGroupDB/commit/fa58ef7bc3be00ac936ef7f8d1d9ddbb7cfddb1b applies - sometimes a user may want to submit a subset of the measurements, and they should just be added to other matching measurements.

Or perhaps I mis-understood how to structure the add-in file and there's a way to do that, just not with the way I did it in this commit?

dr-rodriguez commented 4 years ago

Not sure who you attempted to add the data, but I did find a bug in the validator that was preventing add_data from adding valid results.

Here's how you can add a new entry to an existing galaxy:

from galcat.core import *
db = Database(references_file='data_references.json')
db.query({'name': 'Bootes (I)'})[0]['stellar_radial_velocity_dispersion']
doc = {
    "name": "Bootes (I)",
    "stellar_radial_velocity_dispersion": [
        {
            "value": 6.5,
            "error_upper": 2.1,
            "error_lower": 1.3,
            "best": 0,
            "unit": "km/s",
            "reference": "Martin_2007"
        }
    ]
}
db.add_data(doc, update_value=False, validate=True)
db.query({'name': 'Bootes (I)'})[0]['stellar_radial_velocity_dispersion']
db.save_all()  # actually write out to disk
eteq commented 4 years ago

Ah, that's not quite the same as what this issue is about. I was trying to do this: https://github.com/eteq/DSII_LocalGroupDB/commit/2cdeaf1f53374d78851b4e9dae32b00e73aafa8b - i.e., have a second file that refers to the same object, and have that add its measurement.

The use case I'm thinking of here is where an external contributor wants to add their own measurement of an object but they aren't sure what file to put it in. In the above commit they just add only their measurement and are expecting that to appear as an alternative measurement for the Boo I stellar radial velocity dispersion (i.e. get the exact same answer as https://github.com/eteq/DSII_LocalGroupDB/commit/eeb708b85ac9508651144d061e84400807ae3ba1).

This might be a huge can of worms for conflict-checking, but I'm imagining something fairly simple like keying on the object name, measurement type, and reference to check for uniqueness.