Package chianti :: Module ipymputil
[hide private]
[frames] | no frames]

Source Code for Module chianti.ipymputil

  1  ''' 
  2  functions needed for IPython multiprocessing module ipymspectrum 
  3  ''' 
  4  from IPython.parallel import require 
  5  import copy 
  6  import chianti 
7 @require('copy', 'chianti') 8 -def doFf(inpt):
9 ''' multiprocessing helper for freefree''' 10 ionS = inpt[0] 11 temperature = inpt[1] 12 wavelength = inpt[2] 13 abund = inpt[3] 14 cont = chianti.core.continuum(ionS, temperature, abundance=abund) 15 cont.freeFree(wavelength) 16 return [ionS, copy.deepcopy(cont.FreeFree)]
17 #
18 # ---------------------------------------------- 19 # 20 @require('copy', 'chianti') 21 -def doFb(inpt):
22 ''' 23 multiprocessing helper for freeBound 24 ''' 25 ionS = inpt[0] 26 temperature = inpt[1] 27 wavelength = inpt[2] 28 abund = inpt[3] 29 cont = chianti.core.continuum(ionS, temperature, abundance=abund) 30 cont.freeBound(wavelength) 31 return [ionS, copy.deepcopy(cont)]
32 #
33 # ---------------------------------------------- 34 # 35 @require('copy', 'chianti') 36 -def doIon(inpt):
37 ''' 38 multiprocessing helper for ion, also does two-photon 39 ''' 40 # [ionS, temperature, eDensity, wavelength, filter, allLines, abund] 41 ionS = inpt[0] 42 temperature = inpt[1] 43 density = inpt[2] 44 wavelength = inpt[3] 45 wvlRange = [wavelength.min(), wavelength.max()] 46 filter = inpt[4] 47 allLines = inpt[5] 48 abund = inpt[6] 49 em = inpt[7] 50 doContinuum = inpt[8] 51 thisIon = chianti.core.ion(ionS, temperature, density, abundance=abund) 52 thisIon.intensity(wvlRange = wvlRange, allLines = allLines, em=em) 53 if 'errorMessage' not in thisIon.Intensity.keys(): 54 thisIon.spectrum(wavelength, filter=filter, allLines=allLines) 55 # outList = [ionS, thisIon.Spectrum] 56 # outList = [ionS, thisIon.Spectrum, thisIon.Intensity] 57 # outList = [ionS, thisIon] 58 # outList = [ionS, ionS] 59 outList = [ionS, thisIon] 60 if not thisIon.Dielectronic and doContinuum: 61 if (thisIon.Z - thisIon.Ion) in [0, 1]: 62 thisIon.twoPhoton(wavelength, em=em) 63 outList.append(thisIon.TwoPhoton) 64 return outList
65 #
66 # ---------------------------------------------- 67 # 68 @require('copy', 'chianti') 69 -def doAll(inpt):
70 ''' 71 to process ff, fb and line inputs 72 ''' 73 ionS = inpt[0] 74 calcType = inpt[1] 75 if calcType == 'ff': 76 temperature = inpt[2] 77 wavelength = inpt[3] 78 abund = inpt[4] 79 cont = chianti.core.continuum(ionS, temperature, abundance=abund) 80 cont.freeFree(wavelength) 81 return [ionS, calcType, copy.deepcopy(cont.FreeFree)] 82 elif calcType == 'fb': 83 temperature = inpt[2] 84 wavelength = inpt[3] 85 abund = inpt[4] 86 cont = chianti.core.continuum(ionS, temperature, abundance=abund) 87 cont.freeBound(wavelength) 88 return [ionS, calcType, copy.deepcopy(cont)] 89 elif calcType == 'line': 90 temperature = inpt[2] 91 density = inpt[3] 92 wavelength = inpt[4] 93 wvlRange = [wavelength.min(), wavelength.max()] 94 filter = inpt[5] 95 allLines = inpt[6] 96 abund = inpt[7] 97 em = inpt[8] 98 doContinuum = inpt[9] 99 thisIon = chianti.core.ion(ionS, temperature, density, abundance=abund) 100 thisIon.intensity(wvlRange = wvlRange, allLines = allLines, em=em) 101 if 'errorMessage' not in thisIon.Intensity.keys(): 102 thisIon.spectrum(wavelength, filter=filter, allLines=allLines) 103 # outList = [ionS, thisIon.Spectrum] 104 # outList = [ionS, thisIon.Spectrum, thisIon.Intensity] 105 # outList = [ionS, thisIon] 106 # outList = [ionS, ionS] 107 outList = [ionS, calcType, copy.deepcopy(thisIon)] 108 if not thisIon.Dielectronic and doContinuum: 109 if (thisIon.Z - thisIon.Ion) in [0, 1]: 110 thisIon.twoPhoton(wavelength, em=em) 111 outList.append(thisIon.TwoPhoton) 112 return outList
113 #
114 # ---------------------------------------------- 115 # 116 @require('copy', 'chianti') 117 -def doAll1(inpt):
118 ''' 119 to process ff, fb and line inputs 120 ''' 121 ionS = inpt[0] 122 calcType = inpt[1] 123 if calcType == 'ff': 124 temperature = inpt[2] 125 wavelength = inpt[3] 126 abund = inpt[4] 127 cont = chianti.core.continuum(ionS, temperature, abundance=abund) 128 cont.freeFree(wavelength) 129 return [ionS, calcType, copy.deepcopy(cont.FreeFree)] 130 elif calcType == 'fb': 131 temperature = inpt[2] 132 wavelength = inpt[3] 133 abund = inpt[4] 134 cont = chianti.core.continuum(ionS, temperature, abundance=abund) 135 cont.freeBound(wavelength) 136 return [ionS, calcType, copy.deepcopy(cont)] 137 elif calcType == 'line': 138 temperature = inpt[2] 139 density = inpt[3] 140 wavelength = inpt[4] 141 wvlRange = [wavelength.min(), wavelength.max()] 142 filter = inpt[5] 143 allLines = inpt[6] 144 abund = inpt[7] 145 em = inpt[8] 146 doContinuum = inpt[9] 147 # thisIon = chianti.core.ion(ionS, temperature, density, abundance=abund) 148 thisIon = ch.ion(ionS, temperature, density, abundance=abund) 149 thisIon.intensity(wvlRange = wvlRange, allLines = allLines, em=em) 150 if 'errorMessage' not in thisIon.Intensity.keys(): 151 thisIon.spectrum(wavelength, filter=filter, allLines=allLines) 152 # outList = [ionS, thisIon.Spectrum] 153 # outList = [ionS, thisIon.Spectrum, thisIon.Intensity] 154 # outList = [ionS, thisIon] 155 # outList = [ionS, ionS] 156 outList = [ionS, calcType, copy.deepcopy(thisIon)] 157 if not thisIon.Dielectronic and doContinuum: 158 if (thisIon.Z - thisIon.Ion) in [0, 1]: 159 thisIon.twoPhoton(wavelength, em=em) 160 outList.append(thisIon.TwoPhoton) 161 return outList
162