Пример #1
0
chandata = chandra[1].data
stars = fits.open('mag_flux_tables/stars_mag_flux_table.fits')
sdata = stars[1].data

### Restrict objects to those in the Chandra field ###
#tbdata = vari_funcs.chandra_only(tbdata)
#chandata = vari_funcs.chandra_only(chandata)
#sdata = vari_funcs.chandra_only(sdata)

#### Split chandra and xmm ###
#mask = np.isnan(chandata['RA'])
#xmmdata = chandata[mask]
#chandata = chandata[~mask]

## Create arrays of flux values ###
fluxn = vari_funcs.mag5_stacks(tbdata)
fluxchann = vari_funcs.mag5_stacks(chandata)  # for chandra non-stellar objects
sfluxn = vari_funcs.mag5_stacks(sdata)
#fluxxmm = vari_funcs.mag5_stacks(xmmdata)

### remove values that are +/-99 ###
fluxn, tbdata = vari_funcs.no99(fluxn, tbdata)
fluxchann, chandata = vari_funcs.no99(fluxchann, chandata)
sfluxn, sdata = vari_funcs.no99(sfluxn, sdata)
#fluxxmm, xmmdata = vari_funcs.no99(fluxxmm, xmmdata)

#### normalise to 1 ###
#fluxn = vari_funcs.normalise(fluxn)
#fluxchann = vari_funcs.normalise(fluxchann)
#sfluxn = vari_funcs.normalise(sfluxn)
Пример #2
0
### Import required libraries ###
import matplotlib.pyplot as plt #for plotting
from astropy.io import fits #for handling fits
from astropy.table import Table #for handling tables
import numpy as np #for handling arrays
#import math
from astropy.stats import median_absolute_deviation
import vari_funcs #my module to help run code neatly
from matplotlib.mlab import griddata
plt.close('all') #close any open plots

# Import fits table
varydata = fits.open('variable_tables/variable_with06B_mag21_DR11details_modz.fits')[1].data

# Extract magnitude table and error table
mag = vari_funcs.mag5_stacks(varydata)
magerr = vari_funcs.magerr5_stacks(varydata)

# Calculate excess variance
excess = vari_funcs.sigmasq(mag, magerr)
mad = median_absolute_deviation(mag, axis=1)

plt.subplot(231)
plt.scatter(varydata['z_m2'], excess, c=varydata['X-ray'])
plt.xlabel('photometric redshift')
plt.ylabel('excess variance')
plt.xlim(xmin=0)

plt.subplot(232)
plt.scatter(varydata['z_m2'], mad,c=varydata['X-ray'])
plt.xlabel('photometric redshift')
Пример #3
0
#from astropy.table import Table #for handling tables
import numpy as np  #for handling arrays
from astropy.stats import median_absolute_deviation
import vari_funcs  #my module to help run code neatly
plt.close('all')  #close any open plots
#from numpy.lib.recfunctions import append_fields
from photutils import CircularAperture, aperture_photometry

hdr08B = fits.getheader('Images/UDS_08B_K.fits')  # random year (same in all)
const = -hdr08B['CD1_1']  # constant that defines unit conversion for FWHM
semesters = ['05B', '06B', '07B', '08B', '09B', '10B', '11B', '12B']

### get data and create flux and errors array ###
sdata = fits.open('mag_flux_tables/stars_mag_flux_table.fits')[1].data
sflux = vari_funcs.flux5_stacks(sdata)
smag = vari_funcs.mag5_stacks(sdata)
sflux, sdata = vari_funcs.noneg(sflux, sdata)
smag = vari_funcs.mag5_stacks(sdata)

### set up normalised flux ###
sfluxn = np.copy(sflux)
sfluxn = vari_funcs.normalise_flux(sfluxn)

### Limit to same magnitude range as PSFS ###
avgmag = np.nanmean(smag, axis=1)
mask1 = avgmag > 15
mask2 = avgmag <= 19

### Remove any variable stars from sample ###
mad = median_absolute_deviation(sfluxn, axis=1)
mask3 = mad < 0.01
Пример #4
0
            else:
                sigma2 = testerrchange[n - 1]
            break
        allmed2 = np.append(allmed2, med)
        n = n + 1
    newmagerr2 = sigma2 * magerr
    return sigma2, newmagerr2


### Open the fits files and get data ###
tbdata = fits.open('mag_flux_tables/mag_flux_table_best.fits')[1].data
chandata = fits.open('mag_flux_tables/xray_mag_flux_table_best.fits')[1].data
sdata = fits.open('mag_flux_tables/stars_mag_flux_table.fits')[1].data

### extract magnitude arrays ###
allmag = vari_funcs.mag5_stacks(tbdata)
allchanmag = vari_funcs.mag5_stacks(
    chandata)  # for chandra non-stellar objects
allsmag = vari_funcs.mag5_stacks(sdata)

### remove 99s ###
allmag, tbdata = vari_funcs.no99(allmag, tbdata)
allchanmag, chandata = vari_funcs.no99(allchanmag, chandata)
allsmag, sdata = vari_funcs.no99(allsmag, sdata)

#mag, bindata = vari_funcs.fluxbin(20.8, 21, allmag, tbdata)
#magerr = vari_funcs.magerr5_stacks(bindata)
#errchange, newmagerr = add_chi_err(mag, magerr)

# need to run on all fluxbins, like in find_outliers
bins = np.array([13, 15])
Пример #5
0
import vari_funcs  #my module to help run code neatly
plt.close('all')  #close any open plots
#from numpy.lib.recfunctions import append_fields

newmag = np.load('magorderedarray.npy')
newmagerr = np.load('newmagerrarray.npy')
newchanmag = np.load('chanmagorderedarray.npy')
newchanmagerr = np.load('channewmagerrarray.npy')
newsmag = np.load('smagorderedarray.npy')
newsmagerr = np.load('snewmagerrarray.npy')

### Open the fits files and get data ###
tbdata = fits.open('mag_flux_tables/mag_flux_table_best.fits')[1].data

### extract magnitude array ###
allmag = vari_funcs.mag5_stacks(tbdata)

### remove 99s ###
allmag, tbdata = vari_funcs.no99(allmag, tbdata)
#allmag = vari_funcs.normalise_mag(allmag)
### get error array ###
magerr = vari_funcs.magerr5_stacks(tbdata)

### get correction info ###
corrections = np.load('chisquarecorrections.npy')

obmag = allmag[5200, :]
oberr = magerr[5200, :]
meanmag = np.nanmean(obmag)
newoberr = np.sqrt(np.square(oberr) + np.square(corrections[1, 39]))