Lv1_spectral_renorm.py
def renorm_spectra(obsid,bary):
    """
    Renormalizing the NICER spectral data with the 'ratios of residuals' sent by
    Jack. See email from 4 Feb 2019.

    obsid - Observation ID of the object of interest (10-digit str)
    bary - Whether the data is barycentered. True/False
    """
    if type(obsid) != str:
        raise TypeError("ObsID should be a string!")
    if bary != True and bary != False:
        raise ValueError("bary should either be True or False!")

    renorm_file = Lv0_dirs.NICER_DATADIR + 'crabcor.dat' #file name for the renormalization ratios
    chan,ratio = np.loadtxt(renorm_file,usecols=(0,1),unpack=True) #loading the channel and ratio values

    orig_spectral = Lv0_dirs.NICER_DATADIR + obsid + '/xti/event_cl/' + obsid+'_spec.pi' #spectral file you want to renormalize
    event = fits.open(orig_spectral)

    orig_chan = event[1].data['CHANNEL'] #extracting the channel values from the spectral file
    orig_counts = event[1].data['COUNTS'] #extracting the count rate from the spectral file

    if len(orig_chan) != len(chan):
        return ValueError(obsid+ ": The number of channels from the renormalization ratio file is not equal to that of the number of channels in the spectral file. Make the necessary alterations!")

    renormalized = orig_counts/ratio
    event[1].data['COUNTS'] = renormalized

    event.writeto(Lv0_dirs.NICER_DATADIR + obsid + '/xti/event_cl/' + obsid + '_renormspec.pi',overwrite=True)

    Renormalizing the NICER spectral data with the 'ratios of residuals' sent by
    Jack. See email from 4 Feb 2019.

    obsid - Observation ID of the object of interest (10-digit str)
    bary - Whether the data is barycentered. True/False
    
Renormalizing the NICER spectral data with the 'ratios of residuals' sent by
Jack. See email from 4 Feb 2019.

Observation ID of the object of interest (10-digit str)
bary - Whether the data is barycentered. True/False
Renormalizing the NICER spectral data with the ' ratios of residuals ' sent by Jack . See email from 4 Feb 2019 . Observation ID of the object of interest ( 10 - digit str ) bary - Whether the data is barycentered . True / False
def renorm_spectra(obsid,bary):
    if type(obsid) != str:
        raise TypeError("ObsID should be a string!")
    if bary != True and bary != False:
        raise ValueError("bary should either be True or False!")
    renorm_file = Lv0_dirs.NICER_DATADIR + 'crabcor.dat' 
    chan,ratio = np.loadtxt(renorm_file,usecols=(0,1),unpack=True) 
    orig_spectral = Lv0_dirs.NICER_DATADIR + obsid + '/xti/event_cl/' + obsid+'_spec.pi' 
    event = fits.open(orig_spectral)
    orig_chan = event[1].data['CHANNEL'] 
    orig_counts = event[1].data['COUNTS'] 
    if len(orig_chan) != len(chan):
        return ValueError(obsid+ ": The number of channels from the renormalization ratio file is not equal to that of the number of channels in the spectral file. Make the necessary alterations!")
    renormalized = orig_counts/ratio
    event[1].data['COUNTS'] = renormalized
    event.writeto(Lv0_dirs.NICER_DATADIR + obsid + '/xti/event_cl/' + obsid + '_renormspec.pi',overwrite=True)
def renorm_spectra ( obsid , bary ) : if type ( obsid ) != str : raise TypeError ( "ObsID should be a string!" ) if bary != True and bary != False : raise ValueError ( "bary should either be True or False!" ) renorm_file = Lv0_dirs . NICER_DATADIR + 'crabcor.dat' chan , ratio = np . loadtxt ( renorm_file , usecols = ( 0 , 1 ) , unpack = True ) orig_spectral = Lv0_dirs . NICER_DATADIR + obsid + '/xti/event_cl/' + obsid + '_spec.pi' event = fits . open ( orig_spectral ) orig_chan = event [ 1 ] . data [ 'CHANNEL' ] orig_counts = event [ 1 ] . data [ 'COUNTS' ] if len ( orig_chan ) != len ( chan ) : return ValueError ( obsid + ": The number of channels from the renormalization ratio file is not equal to that of the number of channels in the spectral file. Make the necessary alterations!" ) renormalized = orig_counts / ratio event [ 1 ] . data [ 'COUNTS' ] = renormalized event . writeto ( Lv0_dirs . NICER_DATADIR + obsid + '/xti/event_cl/' + obsid + '_renormspec.pi' , overwrite = True )
Renormalizing the NICER spectral data with the 'ratios of residuals' sent by
Jack.
Renormalizing the NICER spectral data with the ' ratios of residuals ' sent by Jack .
"""
    Renormalizing the NICER spectral data with the 'ratios of residuals' sent by
    Jack. See email from 4 Feb 2019.

    obsid - Observation ID of the object of interest (10-digit str)
    bary - Whether the data is barycentered. True/False
    """ #file name for the renormalization ratios #loading the channel and ratio values #spectral file you want to renormalize #extracting the channel values from the spectral file #extracting the count rate from the spectral file
obsid
bary