示例#1
0
def fastMAPmap(datapath,ironmap, oxygen1map, oxygen2map, basepath='/Users/jhamer/Research/Data'):
    """NAME: BMAPmap 
    PURPOSE: Returns the MAP solution for B for each pixel in the sun. 
    INPUTS:  datapath        - The final directory in which the FITS files are located
             ironmap         - The array of indices of the iron line core.
             oxygen1map       - The array of indices of the first oxygen line core
             oxygen2map       - The array of indices of the second oxygen line core
    OUTPUTS: marginalmap     - An array of the MAP solution for B for each pixel
    EXAMPLE: 
    """    
    dispersion=Dispersion(oxygen1map=oxygen1map, oxygen2map=oxygen2map) #angstroms/wavelength pixel
    lambdanaughts=LambdaNaught(ironmap=ironmap, oxygen1map=oxygen1map,dispersion=dispersion) #wavelength of iron line core
    alphas=Alpha(lambdanaught=lambdanaughts) #alpha values for each pixel
    fMAPmap=[]
    BMAPmap=[]
    for i in np.arange(1135,1165,1): #currently only calculating for a region
        print(i, str(datetime.now()))
        frow=[]
        Brow=[]
        ssI=v9s.SingleStokes(datapath=datapath, stokes='I', slicenumber=i, basepath=basepath) #row stokes I data
        ssV=v9s.SingleStokes(datapath=datapath, stokes='V', slicenumber=i, basepath=basepath) #row stokes V data
        for j in np.arange(440, 470,1): #currently only calculating for a region
            if lambdanaughts[i][j]==0:
                frow.append(0) #if the pixel is not on the Sun, the most likely value is zero
                Brow.append(0) #if the pixel is not on the Sun, the most likely value is zero
            else:
                fMAP, BMAP=FastMAP(Islicedata=ssI, Vslicedata=ssV, col=j, dispersion=dispersion[i][j], alpha=alphas[i][j], ironloc=ironmap[i][j], sigmamax=3000., sigmamin=1.)
                frow.append(fMAP)
                Brow.append(BMAP)
        fMAPmap.append(frow)
        BMAPmap.append(Brow)
    return fMAPmap, BMAPmap    
示例#2
0
def Bfullmarginal(datapath, ironmap, oxygen1map, oxygen2map):
    """NAME: Bfullmarginal 
    PURPOSE: Returns the pdf for B for each pixel in the disk of the sun
    INPUTS:  datapath        - The final directory in which the FITS files are located
             ironmap         - The array of indices of the iron line core.
             oxygen1map       - The array of indices of the first oxygen line core
             oxygen2map       - The array of indices of the second oxygen line core
    OUTPUTS: marginalmap     - An array for pdfs for B for each pixel
    EXAMPLE: 
    """   
    dispersion=Dispersion(oxygen1map=oxygen1map, oxygen2map=oxygen2map) #angstroms/wavelength pixel
    lambdanaughts=LambdaNaught(ironmap=ironmap, oxygen1map=oxygen1map,dispersion=dispersion) #wavelength of iron line core
    alphas=Alpha(lambdanaught=lambdanaughts) #alpha values for each pixel
    marginalmap=[]
    for i in range(2048):
        row=[]
        ssI=v9s.SingleStokes(datapath=datapath, stokes='I', row=i) #row stokes I data
        ssV=v9s.SingleStokes(datapath=datapath, stokes='V', row=i) #row stokes V data
        for j in range(2048):
            if lambdanaughts[i][j]==0:
                pdf=np.zeros(400)
                pdf[199]=1 #if the pixel is not on the Sun, you want the most likely value to be B=0
                row.append(pdf)
            else:
                row.append(Bpixelmarginal(Islicedata=ssI, Vslicedata=ssV, col=j, dispersion=dispersion[i][j], alpha=alphas[i][j], ironloc=ironmap[i][j], sigmamax=3000., sigmamin=1., integration='quad'))
        marginalmap.append(row)
    return marginalmap
示例#3
0
def BMAPmap(datapath, ironmap, oxygen1map, oxygen2map):
    """NAME: BMAPmap 
    PURPOSE: Returns the MAP solution for B for each pixel in the sun. 
    INPUTS:  datapath        - The final directory in which the FITS files are located
             ironmap         - The array of indices of the iron line core.
             oxygen1map       - The array of indices of the first oxygen line core
             oxygen2map       - The array of indices of the second oxygen line core
    OUTPUTS: marginalmap     - An array of the MAP solution for B for each pixel
    EXAMPLE: 
    """    
    dispersion=Dispersion(oxygen1map=oxygen1map, oxygen2map=oxygen2map) #angstroms/wavelength pixel
    lambdanaughts=LambdaNaught(ironmap=ironmap, oxygen1map=oxygen1map,dispersion=dispersion) #wavelength of iron line core
    alphas=Alpha(lambdanaught=lambdanaughts) #alpha values for each pixel
    MAPmap=[]
    for i in np.arange(1470,1490,1): #currently only calculating for a region
        print(i, str(datetime.now()))
        row=[]
        ssI=v9s.SingleStokes(datapath=datapath, stokes='I', row=i) #row stokes I data
        ssV=v9s.SingleStokes(datapath=datapath, stokes='V', row=i) #row stokes V data
        for j in np.arange(1445, 1465,1): #currently only calculating for a region
            if lambdanaughts[i][j]==0:
                row.append(0) #if the pixel is not on the Sun, the most likely value is zero
            else:
                MAP=BpixelMAP(Islicedata=ssI, Vslicedata=ssV, col=j, dispersion=dispersion[i][j], alpha=alphas[i][j], ironloc=ironmap[i][j], sigmamax=3000., sigmamin=1., integration='quad')
                row.append(MAP)
        MAPmap.append(row)
    return MAPmap       
示例#4
0
def IndexMaps(datapath, array):
    """NAME: IndexMap 
    PURPOSE: Given a folder of FITS files and an array of full disk intensity information, return an array containing the index of the core of the absorption line.
    INPUTS:  datapath       - The folder name containing all of the FITS files for each slice.
             array          - The array of full-disk intensity information.
             line           - The absorption line to look at: Calcium or Oxygen
    OUTPUTS: indexmap       - The array containing the indices of the core of the absorption line for each pixel.
    EXAMPLE: 
            In [6]: datapath='k4v9s160517t213238_oid114635206372132_cleaned'
                    disk=fits.getdata('/Users/jhamer/Research/Output/k4v9s160517t213238/FullDiskPlots /k4v9s160517t213238_oid114635206372132_cleanedI80fulldisk.fits')
                    indexmap=CL.IndexMap(datapath, disk[1020:1028])
            In [7]: indexmap[4][29:35]
            Out[7]: array([  0.   ,   0.   ,  63.016,  60.264,  61.748,  61.472])
    """
    ironmap=np.zeros(len(array))
    oxygen1map=np.zeros(len(array))
    oxygen2map=np.zeros(len(array))
    solarboolean=LF.ContainsSun(datapath=datapath, disk=array)
    gapcols=LF.GapCols(datapath)
    limbs=LF.LimbIndices(datapath, array, solarboolean)
    slicedata=v9s.SingleStokes(datapath=datapath, stokes='I', slicenumber=1024)
    j=0
    while(j<2048):
        PixelIndices(slicedata, ironmap,  j, line='Iron')
        PixelIndices(slicedata, oxygen1map,  j, line='Oxygen1')
        PixelIndices(slicedata, oxygen2map,  j, line='Oxygen2')
        j=j+1
    return ironmap, oxygen1map, oxygen2map
示例#5
0
import os
os.chdir('/Users/jhamer/Research/Scripts/Synthetic/')
import v9sDataHandler as v9s
import WeakFieldApprox as WFA
#import FourParamWFA as FPW
import CoreLocation as CL
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime
from astropy.io import fits
os.chdir('/Users/jhamer/Research/Data/')
datapath = 'k4v9s160617t000000_1024_wfa_noscat'
ls = ['I', 'Q', 'U', 'V']
stokes = []
for l in ls:
    stokes.append(v9s.SingleStokes(datapath, l))
fe, ox1, ox2 = CL.IndexMaps(datapath, stokes[0][70])
dispersion = WFA.Dispersion(ox1, ox2)
lambdanaught = WFA.LambdaNaught(fe, ox1, dispersion)
alpha = WFA.Alpha(lambdanaught)
#beta=FPW.Beta(lambdanaught)
Islicedata = stokes[0]
#Qslicedata=stokes[1]
#Uslicedata=stokes[2]
Vslicedata = stokes[3]
col = 256
dispersion = dispersion[col]
alpha = alpha[col]
#beta=beta[col]
ironloc = fe[col]
params = fits.getdata('/Users/jhamer/Downloads/synth_spec_params.fits')