generated from erosita/uds
na Kubani
This commit is contained in:
@@ -6,11 +6,15 @@ __copyright__ = "Space Research Institute (IKI)"
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from astropy.io import fits
|
||||
from astropy.wcs import WCS
|
||||
from astropy import wcs
|
||||
from astropy.table import Table, Column
|
||||
import matplotlib.pyplot as plt
|
||||
import math, sys
|
||||
import pickle
|
||||
|
||||
|
||||
|
||||
from sklearn.linear_model import LinearRegression
|
||||
from sklearn.linear_model import HuberRegressor
|
||||
from sklearn.linear_model import RANSACRegressor
|
||||
@@ -18,6 +22,12 @@ from sklearn.linear_model import TheilSenRegressor
|
||||
from sklearn.model_selection import cross_val_score
|
||||
from sklearn.model_selection import RepeatedKFold
|
||||
|
||||
from astropy.coordinates import SkyCoord # High-level coordinates
|
||||
from astropy.coordinates import ICRS, Galactic, FK4, FK5 # Low-level frames
|
||||
from astropy.coordinates import Angle, Latitude, Longitude # Angles
|
||||
import astropy.units as u
|
||||
|
||||
|
||||
#from statsmodels.robust.scale import huber
|
||||
from astropy.stats import sigma_clip
|
||||
from numpy import absolute
|
||||
@@ -26,10 +36,10 @@ from numpy import arange
|
||||
from ridge.utils import *
|
||||
from ridge.config import *
|
||||
|
||||
plotme=True
|
||||
plotme=False
|
||||
enkey = sys.argv[1]
|
||||
#outkey = sys.argv[2]
|
||||
outkey = "BKG"
|
||||
outkey = sys.argv[2]
|
||||
#outkey = "BKG"
|
||||
|
||||
fn="detcnts.{}.fits".format(enkey)
|
||||
|
||||
@@ -83,6 +93,13 @@ base0=[]
|
||||
c0=[]
|
||||
texp0=[]
|
||||
|
||||
hdulist = fits.open(datadir+modelrxte)
|
||||
w = wcs.WCS(hdulist[0].header)
|
||||
smap = hdulist[0].data
|
||||
sx=int(hdulist[0].header['NAXIS1'])
|
||||
sy=int(hdulist[0].header['NAXIS2'])
|
||||
|
||||
|
||||
#d = fits.getdata(datadir+fn)
|
||||
#df = pd.DataFrame(np.array(d).byteswap().newbyteorder())
|
||||
|
||||
@@ -110,6 +127,18 @@ BKG 61214 ScWs, 114.3 Ms
|
||||
Total 131440 ScWs, 225.9 Ms
|
||||
"""
|
||||
|
||||
|
||||
# fill AITOF map indexes
|
||||
ds9x=[]
|
||||
ds9y=[]
|
||||
|
||||
"""
|
||||
for i,row in df.iterrows():
|
||||
#print(x,y,smap[y-1,x-1])
|
||||
df['DS9Y']=ds9x
|
||||
df['DS9X']=ds9y
|
||||
"""
|
||||
|
||||
for i, row in df.iterrows():
|
||||
orbit=row['REV']
|
||||
obsid=row['OBSID']#.decode("UTF-8")
|
||||
@@ -171,6 +200,17 @@ for i, row in df.iterrows():
|
||||
lon0.append(row['LON'])
|
||||
lat0.append(row['LAT'])
|
||||
|
||||
lon=row['LON']
|
||||
lat=row['LAT']
|
||||
world = SkyCoord(lon,lat, frame=Galactic, unit="deg")
|
||||
ra=world.fk5.ra.deg
|
||||
dec=world.fk5.dec.deg
|
||||
pixcrd = w.wcs_world2pix([(lon,lat)], 1)
|
||||
x=int(pixcrd[0][0])
|
||||
y=int(pixcrd[0][1])
|
||||
ds9x.append(x)
|
||||
ds9y.append(y)
|
||||
|
||||
print("N={} ScWs, {:.1f} Ms".format(len(resid0),np.sum(texp0)/1e6))
|
||||
|
||||
sigma=3
|
||||
@@ -222,7 +262,7 @@ if(plotme):
|
||||
plt.xlabel("Residuals, mCrab")
|
||||
plt.show()
|
||||
|
||||
with open(proddir+fn.replace(".fits",".ignored_rev.resid.pkl"), 'wb') as fp:
|
||||
with open(proddir+fn.replace(".fits",".{}.ignored_rev.resid.pkl".format(outkey)), 'wb') as fp:
|
||||
pickle.dump(drev[filtered_arr.mask==True], fp, protocol=pickle.HIGHEST_PROTOCOL)
|
||||
print("Removed REVs:",drev[filtered_arr.mask==True])
|
||||
|
||||
@@ -254,6 +294,8 @@ coldefs = fits.ColDefs([
|
||||
fits.Column(name='A', format='D', unit='', array=[a0[index] for index in indices]),
|
||||
fits.Column(name='B', format='D', unit='', array=[b0[index] for index in indices]),
|
||||
fits.Column(name='C', format='D', unit='', array=[c0[index] for index in indices]),
|
||||
fits.Column(name='DS9X', format='D', unit='', array=[ds9x[index] for index in indices]),
|
||||
fits.Column(name='DS9Y', format='D', unit='', array=[ds9y[index] for index in indices]),
|
||||
])
|
||||
|
||||
fout = fn.replace(".fits",".{}.resid.fits".format(outkey))
|
||||
|
Reference in New Issue
Block a user