In [1]:
import numpy as np
import pandas as pd
import gc

import matplotlib.pyplot as plt
%matplotlib notebook

First - test to see if there are any stars that would be selected by the parallax criterion, but not by the proper motion criterion.


In [2]:
gaia_dir = "/Users/adamamiller/Desktop/PS1_fits/gaia_stars/"
gaia_df = pd.read_hdf(gaia_dir + "parallax_ps1_gaia_mag_pm_plx.h5")
pxl_not_pm = np.where((gaia_df["parallax_over_error"] >= 8) & 
                      (gaia_df["pm_over_error"] < 7.5))

In [3]:
gaia_df.iloc[pxl_not_pm]


Out[3]:
objid pm_over_error parallax_over_error g_mag
109 108000558702683922 4.992758 11.878710 17.258440
146 108000679395059808 5.923615 8.007660 18.647120
184 108000753956420501 5.135121 9.707506 16.752054
191 108000764310144999 6.794067 8.487449 19.225445
201 108000776745494554 7.314615 15.286850 16.418072
236 108000807671276252 5.076812 19.332268 17.940525
247 108000815963484935 4.900018 74.821198 13.828594
285 108000867232342350 3.925954 12.368188 17.717985
286 108000868086405552 5.405010 59.018345 14.168565
318 108000898948784126 7.152426 10.417873 18.761436
319 108000900104315588 6.427175 12.600371 15.254137
331 108000909237988130 4.521032 14.873709 14.458749
369 108000937431100787 6.079728 9.056735 16.382675
386 108000946271478005 6.565938 9.856745 16.708897
454 108000976362701189 5.334060 8.062293 17.080667
456 108000977799409336 3.804061 17.446152 15.097472
588 108001032632073993 3.470938 12.541704 14.927606
590 108001033313802419 4.584049 10.191030 17.070740
591 108001033361471544 6.613405 12.435500 16.952473
625 108001045734103432 2.940922 8.704594 13.428574
636 108001050263365072 7.439460 9.895067 16.935173
656 108001059074165993 5.331483 9.838800 13.867712
695 108001072022534356 7.330032 11.822950 16.596714
734 108001088391749498 2.838388 11.413535 14.451580
804 108001122110133303 4.184611 11.490471 14.568737
1312 108002402504505614 7.100734 12.393390 15.278312
1394 108002560629165960 4.082439 9.451392 18.223091
1438 108002630684711539 7.008520 9.604712 18.008642
1441 108002631628648569 5.606097 17.064999 18.389467
1589 108002734065125522 7.256816 13.549193 17.387547
... ... ... ... ...
38762302 107990934367794606 6.657876 13.527452 17.383444
38762331 107990951725734167 5.328002 11.149290 16.847481
38762347 107990958003641795 2.543471 11.976346 14.552135
38762486 107991021548846260 4.196245 8.383924 16.221577
38762519 107991038484652431 4.096737 15.169721 13.110353
38762548 107991050781432518 2.738570 10.893595 15.240683
38762606 107991071684488443 5.719890 8.349390 13.467265
38762621 107991080415364103 1.182838 9.015607 17.539293
38762700 107991112356670901 4.922451 13.096426 15.490590
38762899 107991215863234004 1.641713 9.102999 17.454494
38762902 107991217884384008 6.006647 8.644845 17.573864
38763004 107991347621517584 7.493693 14.597059 14.894972
38763136 107991923407093260 5.808019 10.562899 17.426758
38763371 107992603898770781 4.108803 8.359377 18.072027
38763414 107992641107080678 6.884237 8.784234 18.886114
38763418 107992645044281515 6.326950 8.102049 15.466605
38763572 107992741150251488 5.280957 14.802033 16.562408
38763617 107992788965764266 6.874857 10.369900 17.082569
38763695 107992840343779445 3.795407 9.943432 17.007366
38763736 107992850494447803 4.699612 11.322051 15.981968
38763737 107992850605047796 6.046919 17.953314 15.713612
38763921 107992904801759112 6.959065 24.393904 14.099610
38763940 107992911699036959 6.281943 8.308596 17.169621
38764015 107992942883479381 6.336517 8.688941 16.491434
38764055 107992960019918013 5.076989 10.064295 16.161171
38764068 107992966682638588 4.246874 13.251598 15.938543
38764130 107992999749506387 5.093741 8.937325 16.341532
38764190 107993034062396840 6.625312 8.751449 16.704084
38764293 107993142918542204 3.366576 21.362116 14.817825
38764546 108003194850820253 7.308362 8.673074 15.197629

579597 rows × 4 columns

There are ~579k sources that satisfy the pxl cut but not the pm cut. These now need to be matched to the pxl cut stars in PS1 to see which (if any) of these stars need to be adjusted in the ZTF database.


In [4]:
pxl_ps1 = pd.read_hdf("parallax_ps1_gaia_cat_merge.h5")

In [5]:
pxl_objid = np.array(gaia_df["objid"].iloc[pxl_not_pm])
pxl_ps1_objid = np.array(pxl_ps1.index)
pxl_in_cat = np.isin(pxl_objid, pxl_ps1_objid)

In [6]:
print("There are {} pxl stars that need to be added to the catalog".format(len(pxl_objid[~pxl_in_cat])))


There are 26658 pxl stars that need to be added to the catalog

In [7]:
pxl_objid[~pxl_in_cat]


Out[7]:
array([108001045734103432, 108020229828629738, 108020819165603548, ...,
       107983201466254882, 107990865774634072, 107992840343779445])

In [8]:
del pxl_ps1
del gaia_df
gc.collect()


Out[8]:
51

Get the missing pm stars


In [9]:
gaia_dir = "/Users/adamamiller/Desktop/PS1_fits/gaia_stars/"
pm_df = pd.read_hdf(gaia_dir + "pm_ps1_gaia_mag_pm_plx.h5")

In [10]:
pm_ps1 = pd.read_hdf("pm_ps1_gaia_cat_merge.h5")

In [11]:
pm_objid = np.array(pm_df["objid"])
pm_ps1_objid =np.array(pm_ps1.index)

In [12]:
del pm_df
del pm_ps1
gc.collect()


Out[12]:
102

In [13]:
pm_in_cat = np.isin(pm_objid, pm_ps1_objid)

In [14]:
pxl_and_pm_objid = np.append(pm_objid[~pm_in_cat],
                             pxl_objid[~pxl_in_cat])

In [15]:
new_stars_df = pd.DataFrame(pxl_and_pm_objid, columns=["objid"])

In [17]:
new_stars_df.to_hdf("objid_for_gaia_stars_for_ztf_database.h5", "d1")

In [ ]: