forked from davecoulter/YSE_PZ
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FRB Status + KKO
- Loading branch information
Showing
24 changed files
with
987 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" Build up the Test DB (may be more than one option)""" | ||
|
||
import datetime | ||
import os | ||
from pkg_resources import resource_filename | ||
|
||
from django.contrib import auth | ||
|
||
import pandas | ||
|
||
from YSE_App.models import * | ||
from YSE_App.chime import chime_test_utils as ctu | ||
from YSE_App import frb_init | ||
from YSE_App import frb_status | ||
from YSE_App import frb_utils | ||
|
||
def init_kko(clean:bool=True): | ||
""" Build the CHIME KKO DB from scratch """ | ||
|
||
user = auth.authenticate(username='root', password='F4isthebest') | ||
|
||
# Clean first | ||
ctu.clean_all(skip_resources=True) | ||
|
||
# ############################## | ||
# Init the DB | ||
# Status | ||
frb_init.init_statuses(user) | ||
|
||
# Observing Groups | ||
frb_init.init_obsgroups(user) | ||
|
||
# Load up the table | ||
csv_file = os.path.join( | ||
resource_filename('YSE_App', 'chime'), 'chime_kko_sep2023.csv') | ||
df_frbs = pandas.read_csv(csv_file) | ||
|
||
# Add CHIME Observation Group? | ||
survey_names = [survey.name for survey in FRBSurvey.objects.all()] | ||
for survey in ['CHIME/FRB']: | ||
if survey not in survey_names: | ||
obs = FRBSurvey(name=survey, created_by_id=user.id, modified_by_id=user.id) | ||
obs.save() | ||
|
||
# Add em | ||
transients = ctu.add_df_to_db(df_frbs, user, | ||
delete_existing=False) | ||
|
||
# Set the KKO tag | ||
kko_tag = frb_utils.add_or_grab_obj( | ||
FRBTag, dict(name='CHIME-KKO'), {}, user) | ||
unkn_tag = frb_utils.add_or_grab_obj( | ||
FRBTag, dict(name='CHIME-Unknown'), {}, user) | ||
for transient in transients: | ||
# Drop unknown | ||
transient.frb_tags.remove(unkn_tag) | ||
# | ||
transient.frb_tags.add(kko_tag) | ||
# Update status (and save) | ||
frb_status.set_status(transient) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.