Skip to content

Commit

Permalink
Sdss id zway (#425)
Browse files Browse the repository at this point in the history
* Added creation of catalogidx_to_catalogidy for xmatch versions 21, 25, 31

* Removed old files

* Added append_* and some create_I functionality

* Fixing weird peewee things and changing some queries over to raw SQL

* Finished ability to append sdss_ids

* Switched to single model for sdss_id_*

* Transferred sdss_id scripts to /python and fixed bugs

* Turned off saving log to file

* Switched from sandbox to catalogdb

* Switched back to sandbox because of the fear

* Switched to catalogdb instead of the sandbox. Removed unnecessary comments

* Documented sdss_id pk sequences

* Testing git rm --cached

* Removing unnecessary files

* Added comments to add_pk_defaults_to_sdss_id_tables.sql

* Fixed some linting issues

* Cloned python scripts from python/ to documentation

* Added documentation and fixed linting issues

* Fixed more linting issues

* Fixed more linting issues

* Fixed isort errors

* Converted functions to CamelCase

* Moving scripts to sdss_id submodule

* Fixed __init__ imports

* Fixed local import for __init__ and append_to_sdss_id

* Fixed linting issue

* Changed 'to_add' terminology to 'addendum'

* Fixed __init__.py imports

* Linting issues with ruff

* Fixing linting again

* Linting again?

* Typo

* Added outer join on sdss_id_flat

* Fixed import SdssIdFlat

* Changed import of SdssIdFlat in create_catalogidx...

* switch to sandbox

* Removed panstarrs split_query

* Added last_updated column to sdss_id_stacked

* Expanded Examples at end of append_to_sdss_id

* Fixed typo

* Fixed temp_catalogid_v? missing catalogids

* Added default option of running on targetdb

* Added example of running on targetdb

* Linting and changed to TempMatch.create_table()

* Changed to UniqueMatch.create_table()

* Added indexes to SdssIdStackedAddendum

* Manually added indexing

* Editted create_temp_catalogid_lists to allow for
Targetdb

* Typo 'catalgid'

* Shortened TempMatch index labels

* Shortened index labels in Unique Match

* Added new catalogs to individual_crossmatches

* Added Rank to SdssIdFlatAddendum

* rank in SdssIdFlatAddendum is nullable

* Rank joins on sdss_id/catalogid pair instead of pk

* Typo "Rank" to "rank"

* Added documentation

* Linting issues

* More Linting?

* More more linting

* Linting issues

* Added README to catalog_to_catalog

---------

Co-authored-by: Zachary Way <zway1@gsu.edu>
  • Loading branch information
zachway1996 and Zachary Way authored Nov 14, 2024
1 parent b8e8c22 commit a6569d6
Show file tree
Hide file tree
Showing 17 changed files with 2,034 additions and 52,681 deletions.
6 changes: 6 additions & 0 deletions docs/v1_documentation/catalog_to_catalog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This directory "catalog_to_catalog" was originally developed by Felipe and then
edited by Zach to create the original sdss_id. It is kept here for historical
purposes but is not the code that is used to update sdss_id. That can be found in
python/target_selection/sdss_id

If you have questions about these files, feel free to reacho out to Zach Way at zway1@gsu.edu
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- This script creates sequences for the primary keys (sdss_id and pk) in the two sdss_id tables
-- This should be run after the sdss_id tables are created so that the sdss_ids can be automatically assigned

CREATE SEQUENCE catalogdb.sdss_id_stacked_sdss_id__seq;
ALTER TABLE catalogdb.sdss_id_stacked ALTER COLUMN sdss_id SET DEFAULT nextval('catalogdb.sdss_id_stacked_sdss_id__seq');
ALTER SEQUENCE catalogdb.sdss_id_stacked_sdss_id__seq OWNED BY catalogdb.sdss_id_stacked.sdss_id;
SELECT setval('catalogdb.sdss_id_stacked_sdss_id__seq', (SELECT MAX(sdss_id) FROM catalogdb.sdss_id_stacked));

CREATE SEQUENCE catalogdb.sdss_id_flat_pk__seq;
ALTER TABLE catalogdb.sdss_id_flat ALTER COLUMN pk SET DEFAULT nextval('catalogdb.sdss_id_flat_pk__seq');
ALTER SEQUENCE catalogdb.sdss_id_flat_pk__seq OWNED BY catalogdb.sdss_id_flat.pk;
SELECT setval('sandbox.sdss_id_flat_pk__seq', (SELECT MAX(pk) from catalogdb.sdss_id_flat));
23 changes: 23 additions & 0 deletions docs/v1_documentation/catalog_to_catalog/add_ra_dec.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
UPDATE sandbox.sdss_id_stacked sid
SET ra = cat.ra,
dec = cat.dec
FROM catalog cat
WHERE sid.catalogid31=cat.catalogid
and sid.catalogid31 is not NULL;

UPDATE sandbox.sdss_id_stacked sid
SET ra = cat.ra,
dec = cat.dec
FROM catalog cat
WHERE sid.catalogid25=cat.catalogid
and sid.catalogid31 is NULL
and sid.catalogid25 is not NULL;

UPDATE sandbox.sdss_id_stacked sid
SET ra = cat.ra,
dec = cat.dec
FROM catalog cat
WHERE sid.catalogid21=cat.catalogid
and sid.catalogid31 is NULL
and sid.catalogid25 is NULL
and sid.catalogid21 is not NULL;
478 changes: 478 additions & 0 deletions docs/v1_documentation/catalog_to_catalog/append_to_sdss_id.py

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a6569d6

Please sign in to comment.