Skip to content

Commit

Permalink
Companions table (#385)
Browse files Browse the repository at this point in the history
* First Companion Table Ingest
First ingest into Companions table

[ ] ingest reference not in Simple
[ ] ingest source not in Simple
[ ] import google sheets
[ ] write ingest function

* Start of the companions_first_ingest file

* start of file

* ingest CWISE source and reference

* Add other names function I can only find in the  utils_deprecated file

* Code to ingest a single row itereating through the google sheet

* Code to ingest a single row itereating through the google sheet

* removing files

* added companion function to injest utils with doc string

* fixed angle

* FIXED ANGLE ERROR FROM  FILIP 15

* Add other names function to ingest_utils and replaced code in ingest source

* fix angle

* syntax

* test for Companion Relationship

* created test_names_uniqueness and separtate test_companion_relationship_uniqueness

* syntax changes

* test ingest names code

* small changes syntax

* fixed test

* added some checks for ingest in tests and corrected projected_separation_arcsec naming

* adding schema changes

* adding doc changes

* Revert "adding schema changes"

This reverts commit 4cc3b10.

* Revert "adding doc changes"

This reverts commit 08b0aaa.

* Small changes/debugging

* fixing names of functions and variables

* adjusted names

* add negative tests for modeled parameters

* small syntax

* moved tests

* constrain relatioships

* add doc for CompanionRelationships table

* Update tests/test_utils.py

Co-authored-by: Kelle Cruz <[email protected]>

* small updates

* tests fixed

* add other companion name list as csv. Not sure if discription is clear enough

* updates to make compatable with other comapanion names columns + other companion  names injested in injest file

* small syntax

* small changes

* updated doc

* added checks here to get helpful errors

* small changes

* changes to fix error

* SAVE_DB = True

* data files

* test fixes

* documentation typo

---------

Co-authored-by: kelle <[email protected]>
  • Loading branch information
Ajb2307 and kelle authored Aug 3, 2023
1 parent 1474268 commit 1bd93cd
Show file tree
Hide file tree
Showing 21 changed files with 562 additions and 29 deletions.
11 changes: 11 additions & 0 deletions data/2mass_j02355993-2331205.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "HD 16270",
"projected_separation_arcsec": 11.95,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J02360075-2331167, HD 16270"
}
],
"Names": [
{
"other_name": "2MASS J02355993-2331205"
Expand Down
11 changes: 11 additions & 0 deletions data/2mass_j06462756+7935045.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "HD 46588",
"projected_separation_arcsec": 79.2,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J06461411+7933542, HD 46588"
}
],
"Names": [
{
"other_name": "2MASS J06462756+7935045"
Expand Down
11 changes: 11 additions & 0 deletions data/2mass_j10221489+4114266.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "HD 89744",
"projected_separation_arcsec": 2460.0,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J10221057+4113466, NLTT 24128, HD 89744"
}
],
"ModeledParameters": [
{
"parameter": "T eff",
Expand Down
11 changes: 11 additions & 0 deletions data/2mass_j13054106+2046394.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "BD+21 2486B",
"projected_separation_arcsec": 516.0,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "BD+21 2486B"
}
],
"Names": [
{
"other_name": "2MASS J13054106+2046394"
Expand Down
11 changes: 11 additions & 0 deletions data/2mass_j14165987+5006258.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "HD 125141",
"projected_separation_arcsec": 570.0,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J14160530+5010093, HD 125141"
}
],
"ModeledParameters": [
{
"parameter": "T eff",
Expand Down
11 changes: 11 additions & 0 deletions data/2mass_j21442847+1446077.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "V* HN Peg",
"projected_separation_arcsec": 42.9,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "V* HN Peg"
}
],
"ModeledParameters": [
{
"parameter": "T eff",
Expand Down
6 changes: 6 additions & 0 deletions data/Publications.json
Original file line number Diff line number Diff line change
Expand Up @@ -6916,5 +6916,11 @@
"bibcode": "2023ApJ...946L...6M",
"doi": "10.3847/2041-8213/acb04a",
"description": "The JWST Early-release Science Program for Direct Observations of Exoplanetary Systems II: A 1 to 20 \u03bcm Spectrum of the Planetary-mass Companion VHS 1256-1257 b"
},
{
"reference": "Roth",
"bibcode": "",
"doi": "",
"description": "Rothermich in prep."
}
]
31 changes: 31 additions & 0 deletions data/cwise_j210640.16+250729.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Sources": [
{
"source": "CWISE J210640.16+250729.0",
"ra": 316.66736,
"dec": 25.124719444444445,
"epoch": null,
"equinox": null,
"shortname": null,
"reference": "Roth",
"other_references": null,
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "BD+24 4329",
"projected_separation_arcsec": 1124.0,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": "Roth",
"other_companion_names": "2MASS J21080190+2510346, BD+24 4329"
}
],
"Names": [
{
"other_name": "CWISE J210640.16+250729.0"
}
]
}
11 changes: 11 additions & 0 deletions data/hip_26653b.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "HD 37216",
"projected_separation_arcsec": 27.0,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J05395233+5253508, HD 37216"
}
],
"Names": [
{
"other_name": "2MASS J05394952+5253597"
Expand Down
11 changes: 11 additions & 0 deletions data/hip_38939b.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "HD 65486",
"projected_separation_arcsec": 88.0,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J07580434-2537356, HD 65486"
}
],
"Names": [
{
"other_name": "2MASS J07580132-2538587"
Expand Down
11 changes: 11 additions & 0 deletions data/hip_9269b.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "HD 12051",
"projected_separation_arcsec": 52.1,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J01590663+3312350, HD 12051"
}
],
"Names": [
{
"other_name": "2MASS J01591078+3312313"
Expand Down
11 changes: 11 additions & 0 deletions data/lspm_j0632+5053b.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "LSPM J0632+5053",
"projected_separation_arcsec": 47.4,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J06325350+5053339, LSPM J0632+5053"
}
],
"Names": [
{
"other_name": "LSPM J0632+5053B"
Expand Down
14 changes: 14 additions & 0 deletions data/nltt_1011b.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@
"comments": null
}
],
"CompanionRelationships": [
{
"companion_name": "LP 192-58",
"projected_separation_arcsec": 58.5,
"projected_separation_error": null,
"relationship": "Child",
"comments": null,
"reference": null,
"other_companion_names": "2MASS J00193461+4018061, LP 192-58"
}
],
"Names": [
{
"other_name": "2MASS J00193275+4018576"
},
{
"other_name": "NLTT 1011B"
}
Expand Down
23 changes: 23 additions & 0 deletions documentation/CompanionRelationships.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# CompanionRelationships

The CompanionRelationships table contains companions to sources listed in the Sources table.
The combination of *source* and *companion_name* is expected to be unique.
Columns marked with an asterisk (*) may not be empty.

| Column Name | Description | Unit | Data Type | Key Type |
|---|---|---|---|---|
| *source | Unique identifier for the source | | String(100) | primary and foreign: Sources.source |
| *companion_name | SIMBAD resovable name of companion object | | String(100) | primary |
| projected_separation_arcsec | Projected separation between the source and companion | arcsec | Float | |
| projected_separation_error | Uncertainty of projected separation | arcsec | Float | |
| relationship | Relationship of source to companion. See Notes below. | | String(100) | |
| comments | Free form comments | | String(1000) | |
| reference | Reference | | String(30) | foreign: Publications.name |
| other_companion_names | Comma separated names | | String(1000) | |

## Notes
Relationships are constrained but should be one of the following:
- *Child*: The source is lower mass/fainter than the companion
- *Sibling*: The source is similar to the companion
- *Parent*: The source is higher mass/brighter than the companion
- *Unresolved Parent*: The source is the unresolved, combined light source of an unresolved multiple system which includes the companion
66 changes: 66 additions & 0 deletions scripts/ingests/companions_first_ingest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# script ingest first data into companion tables

from scripts.ingests.ingest_utils import *
from scripts.ingests.utils import *
from astropy.table import Table
import astropy.units as u
from astropy.coordinates import Angle


SAVE_DB = True # save the data files in addition to modifying the .db file
RECREATE_DB = True # recreates the .db file from the data files
VERBOSE = False
# LOAD THE DATABASE
db = load_simpledb('SIMPLE.db', recreatedb=RECREATE_DB)


# Ingest CWISE J210640.16+250729.0 and its reference
ingest_publication(db, doi = None, bibcode = None, publication = "Roth",
description = "Rothermich in prep.", ignore_ads = True)


ra_2106= Angle("21 06 40.1664", u.hour).degree
dec_2507=Angle("+25 07 28.99", u.degree).degree

ingest_sources(db, ["CWISE J210640.16+250729.0"], references="Roth",
ras= [ra_2106],
decs=[dec_2507],
search_db=False)

# Ingest other name for NLTT 1011B (one used in SIMBAD)
# code from deprecated utils does not work
ingest_names(db, 'NLTT 1011B', '2MASS J00193275+4018576')


# start of ingest
# link to live google sheet
link = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQEOZ56agEsAAd6SHVrwXc4hIrTtlCnCNWMefGuKkAXBjius1LgKFbj8fgbL7e8bmLTJbbBIZgwPQrz/pub?gid=0&single=true&output=csv'
#
columns = ['source', 'companion_name', 'projected_separation', 'projected_separation_error', 'relationship', 'comment', 'ref', 'other_companion_names']
companions = Table.read(link, format='ascii', data_start=2, data_end=14, names=columns, guess=False,
fast_reader=False, delimiter=',')


for row in companions:
# collecting variables
source, companion_name, projected_separation_arcsec, relationship = row['source', 'companion_name', 'projected_separation','relationship']

# getting reference if there is one
ref = None
if row['ref'] != '':
ref = row['ref']
# getting other name if there is one
other_companion_names = None
if row['other_companion_names'] != '':
other_companion_names = row['other_companion_names']

# adding row
ingest_companion_relationships(db, source, companion_name, projected_separation_arcsec =projected_separation_arcsec,
relationship = relationship, ref = ref, other_companion_names= other_companion_names)




# WRITE THE JSON FILES
if SAVE_DB:
db.save_database(directory='data/')
6 changes: 3 additions & 3 deletions scripts/ingests/filip_15.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def get_float_value(value, error=False):
return float_value


def get_coords(string):
def get_coords(string, unit = u.degree):
# given RA or Dec as string given in table returns as degree decimals
angle = Angle(string, u.degree)
angle = Angle(string, unit)
return angle.degree


# creating list of dictionaries for each value in table 9 formatted for modeled parameters
modeled_parameters_ingest_dict = [{'source': row['Designation 1'], 'reference': "Fili15",
'ra': get_coords(row['R.A.']), 'dec': get_coords(row['Decl.']),
'ra': get_coords(row['R.A.'], unit = u.hour), 'dec': get_coords(row['Decl.']),
'Radius':
{'value': get_float_value(row['Radius']),
'value_error': get_float_value(row['Radius'], error=True),
Expand Down
Loading

0 comments on commit 1bd93cd

Please sign in to comment.