Sterrekunde

Hoe skep u 'n kontinuummasker in Python of IDL vir 'n ster?

Hoe skep u 'n kontinuummasker in Python of IDL vir 'n ster?


We are searching data for your request:

Forums and discussions:
Manuals and reference books:
Data from registers:
Wait the end of the search in all databases.
Upon completion, a link will appear to access the found materials.

Ek leer hoe ek sterre-spektra kan modelleer met behulp van die IDL-kode, Spectroscopy Made Easy (SME), en sy eweknie Python, PySME. Het iemand al van hierdie programme gebruik gemaak? Soos u kan sien uit die eerste aangehegte prentjie, het die kode probleme met die modellering van die kontinuum wat genormaliseer is. As ek probeer om 'n kontinuummasker in te stel deur golflengte-reekse in te stel (sien tweede afbeelding), word die reekse verskuif in die modellering ... Klaarblyklik is in die Valenti & Fischer 2005-artikel 'n sonspektrum gebruik en dan verskuif? Enige hulp hiermee sal opreg waardeer word.


Alfamenging en maskering van beelde met Python, OpenCV, NumPy

Voer alfamenging en maskering uit met Python, OpenCV, NumPy.

Dit kan slegs met NumPy gerealiseer word sonder om OpenCV te gebruik. Omdat die skikking van NumPy makliker en soepeler is, beveel ek dit aan.

Hierdie artikel beskryf die volgende inhoud.

  • Alfamenging met OpenCV: cv2.addWeighted ()
  • Maskering met OpenCV: cv2.bitwise_and ()
  • Alpha meng met NumPy
  • Maskering met NumPy
  • Komplekse alfamenging en maskering met NumPy
  • Maskerbeeld skep deur OpenCV-tekening

Verwys na die volgende artikel oor alfamenging en maskering met behulp van Pillow (PIL).

Die voorbeeldkode gebruik die volgende afbeelding.

OpenCV-weergawe van die voorbeeldkode is 4.0.1. OpenCV3 en 4 moet nie veel verander nie, maar OpenCV2 kan anders wees, wees dus versigtig.


Verskeie spektroskopie-roetines¶

subfunksies: kalibreer setheaders & # 8211 exptime, gain, readnoise, ens. makeflat & # 8211 maak mediaan plat en raserige pixelkaart makedark & ​​# 8211 maak mediaan donker, en skat geraas in elke pixel.

skoon & # 8211 skoon en vervang slegte pixels-uittreksel

eerste indeks van z waarop data bygevoeg sal word

y0: int of volgorde van inte

tweede indeks van z waarop data bygevoeg sal word

waardes wat by z gevoeg sal word

aanvanklike data, waarby gedeeltelike pixels gevoeg word

Bereken die atmosferiese verspreiding relatief tot lambda_0.

OPROEPVOLG: resultaat = atmosfeer (golf, golf_0, za, druk, temp, [water], [obsalt], $

golf - golflengte in mikron golf_0 - verwysing golflengte in mikron za - hoogte hoek van voorwerp [in grade] druk - atmosferiese druk in mm van Hg temp - atmosferiese temperatuur in grade C

water - waterdampdruk in mm Hg. fco2 - relatiewe konsentrasie van CO2 (deur druk) obsaal - Die observatoriumhoogte in km.

ANNULER - Stel terug as daar 'n probleem is

Wys die atmosferiese verstoring in boogsekondes.

Bereken die verskil tussen die dispersie op twee golflengtes. Die verspreiding vir elke golflengte is afgelei van Afdeling 4.3 van Groen & # 8217s & # 8220Sferiese Sterrekunde & # 8221 (1985).

2000-04-05 - geskryf deur M. Cushing, Institute for Astronomy, UH, 26-07-2002 - het 'n bietjie skoongemaak. 2003-10-20 - gewysigde formule - WDV 2011-10-07 15:51 IJMC: Omgeskakel na Python, met enkele eenheidsomskakelings

spesifikasiekalibreer_staar_mosfire_spectra(scifn, outfn, skycorrect, pixcorrect, subreg_corners, ** kw) [bron] ¶ Korrekte nie-gedideerde WIDE-gleuf MOSFIRE spektrale rame vir:

pixel-tot-pixel-eenvormighede (dws tradisionele platveld)

nie-lineêre opspoorders

skuins spektrale lyne

nie-eenvormige spleetwydtes (wat nie-gladde agtergronde veroorsaak)

Let daarop dat die verspreidingsrigting & # 8216horisontaal & # 8217 (dws parallel met rye) in hierdie raam moet wees.

Lêernaam van rou, ongekalibreerde wetenskapsraamwerk (in ADU's, nie elektrone nie)

Noem waarin die finale, gekalibreerde lêer geskryf moet word.

skycorrect: str of 2D NumPy-skikking

Slitloss-regstellingskaart (dws vir gleuwe met nie-eenvormige breedte), soos gegenereer deur make_spectral_flats () .

pixcorrect: str of 2D NumPy-skikking

Kaart-vir-pixel sensitiwiteitskorrigeringskaart (dws plat veld), soos gegenereer deur make_spectral_flats () .

subreg_corners: volgorde van 2- of 4-reekse

Indekse (of bloot begin- en eindrye) vir elke substreek van belangstelling in & # 8216sky & # 8217 en & # 8216domeflat & # 8217 rame. Sintaksis moet die van wees tools.extractSubregion () , of sodanig dat subreg = sky [subreg_corners [0]: subreg_corners [1]]

Of u die data lineêr moet korrigeer.

As lynvorming: regstelling van die lineariteit word bereken en amp toegepas NADAT die pixel-vir-pixel (platveld) regstelling aangebring is, maar VOOR die regstelling van die spleetverlies (lug).

Binne- en buitenstraal vir agtergrondberekening en -verwydering gemeet in pixels vanaf die middel van die profiel. Die waardes [11,52] werk blykbaar goed vir MOSFIRE K-bandspektra.

Hierdie roetine is stadig, meestal as gevolg van die oproep tot defringe_sinusoid () . Oorweeg dit om verskeie prosesse gelyktydig uit te voer om dinge te bespoedig!

Gebruik 'n eenvoudige pasvorm om rande en lugagtergronde af te trek.

subframe: NumPy array data subframe met sky data wat afgetrek moet word (en, miskien, 'n voorwerp en spektrale spoor). Veronderstel om in ADU te wees, nie elektrone nie (sien versterking en leesgeluid) nmed: int Grootte van venster vir 2D mediaanfilter (om slegte pixels te verwerp, ens.) Dispaxis: int set dispersie-as: 0 = horisontaal en 1 = vertikale ruimtelike_indeks: Geen , of 1D NumPy-skikking van die tipe bool

Let daarop dat (in my ervaring!) Hierdie benadering beter werk as u alle gewigte op eenheid stel, eerder as om die voorgestelde (foton + leesgeruis) afwykings te gebruik.

baarmoeder (vir Lomb-Scargle periodogramme)

SciPy & # 8216signaal & # 8217 module (vir mediaan-filtering)

Wys die beste pas-lugraamwerk.

óf 'n tuple van (splineProfile, profileStack, errorStack, profileMask), óf 'n lys van sulke tuples (van makeprofile).

innerlike en buitenste radiusse om in die rekenaaragtergrond te gebruik

radius om te gebruik vir sowel vloeinormalisering as onttrekking

[0] & # 8211 spektrumstroom (in elektrone)

Let daarop dat dit nie optimaal is met hoogs gekantelde of geboë spektra nie, om die redes beskryf deur Marsh (1989) en Mukai (1990).

Pas twee Gaussers gelyktydig aan op 'n invoer-datavektor.

1D-skikking of lys waardes om aan te pas

raaiparameters: [area1, sigma1, cen1, area2, sig2, cen2, constant]. Let daarop dat parameters in pixeleenhede is.

parameters om vas te hou in analise, _IF_ raai word deurgegee.

Pas 'n Gaussiese funksie by 'n invoer-datavektor.

Stel die pasvorm terug, en onsekerheidsberamings oor die pas.

Pas 'n Gaussiese funksie by 'n invoer-datavektor.

Stel die pasvorm terug, en onsekerheidsberamings oor die pas.

Helperfunksie om 1D PSF naby 'n bepaalde streek te pas. Neem aan dat die spektrum horisontaal oor die raam loop!

ec: 2D gevoelloos skikking echellogram skikking, met horisontale verspreidingsrigting raaiLoc: 2-tuple 'n Geringe verkeerde benaming vir hierdie (x, y) tupel: y is 'n raaiskoot en sal geskik wees, maar x is die koördinaat waarteen die aanpassing plaasvind. pasbreedte: int breedte van die kruisverspreidingsrigting om te gebruik in pasmedia: int aantal kolomme waar die gemiddelde van moet wees as 'n profiel aangebring word: woordelikheid / foutopsporing drukstuk vlag sigma: skalaar sigmaskaal vir die knip van slegte waardes spesifikasiefitProfileSlices(splineProfile, profielStapel, stdProfiel, goeiePixels, verbose = Onwaar, bkg_radii = Geen, extract_radius = Geen) [bron] ¶

Pas 'n gegewe ruimtelike profiel in 'n spektrum

Pas 'n 1D-tophat-funksie op 'n invoer-datavektor.

Stel die pasvorm terug, en onsekerheidsberamings oor die pas.

Pas 'n ruimtelike profiel op 'n splinkklas in 'n spektrum-deursnit

Bereken die integraal van -inf tot x van die genormaliseerde Gaussiese

boonste grens van integrasie

Ontwerp om die IDL-funksie met dieselfde naam te kopieer.

Om relatiewe humiditeit in 'n H2O dampdruk te omskep

RH - relatiewe humiditeit, in persent T - temperatuur, in Kelvin

h2o_pp: waterdamp gedeeltelike druk, in Pascals

Soos uiteengesit in Butler (1998): & # 8220Precipitable Water at KP & # 8221, MMA Memo 238 (wat op sy beurt verwys na Liebe 1989, & # 8220MPM - An Atmospheric Millimeter-Wave Propagation Model & # 8221). Liebe beweer dat hierdie verband 'n fout van & lt0.2% het van -40 C tot +40 C.

2011-10-08 17:08 IJMC: Geskep.

Om die spleetverliese uit 'n spektrum te bepaal.

### TBD lightloss, obj, std, wguide, seeing, out, CANCEL = kanselleer

obj - FITS-lêer van die objektspektrum wgids - golflengte waarop gelei is, sien - sien FWHM op die riggolflengte

pers - mm Hg tipiese waarde (615 vir IRTF, tensy ingestel) water - mm Hg tipiese waarde (2 vir IRTF, tensy ingestel) temp - deg C tipiese waarde (0 vir IRTF, tensy ingestel) fco2 - relatiewe konsentrasie van CO2 (0.004 , tensy dit ingestel is) wobj - golflengteskaal vir data dx - horisontale verskuiwing van ster vanaf spleet sentrum dy - vertikale verstelling van ster vanaf spleet sentrum herhaling - of u baie diagnostiese inligting moet teruggee, of net ligverlies.

& # 8216sien & # 8217, & # 8216dx & # 8217, en & # 8216dy & # 8217 moet almal in dieselfde eenhede wees, en ook dieselfde eenhede wat gebruik word om die spleetafmetings in die obj FITS-lêerkop te definieer.

ANNULER - Stel terug as daar 'n probleem is

skikking: breukdeelverlies by elke golflengtewaarde

tuple van skikkings: (slitloss, disp_obj, diff, fwhm, dx_obj, dy_obj)

Lees 'n Spextool FITS-lêer.

2003-10-21 - Geskryf deur W D Vacca 2011-10-07 20:19 IJMC: Omgeskakel na Python, aangepas vir enkele voorwerpe 2011-10-14 14:01 IJMC: Bygevoegde tjek vir Prisma-modus (het

verskillende sleuteldimensie sleutelwoorde) en verskillende pyfits-kopleesmodus.

2011-11-07 15:53 ​​IJMC: Bygevoeg & # 8216retall & # 8217 sleutelwoord

Om die spleetverliese van 'n waarneming te bepaal (geen FITS-lêer betrokke nie)

### TBD lightloss, obj, std, wguide, seeing, out, CANCEL = kanselleer

wobj - golflengteskaal voor data spleetwd - spleetbreedte, in boogsek-gleuf - spleethoogte, in boogsek spleetPA - spleet Posisiehoek, in radiale doelPA - Parallaktiese hoek op doelwit, in radiale zenith_angle - Zenithhoek, in radiale wiglyn - golflengte by watter leiding gedoen is - sien FWHM op die golflengte

druk - mm Hg tipiese waarde (615, tensy dit ingestel is) water - mm Hg tipiese waarde (2, tensy dit ingestel is) temp - deg C tipiese waarde (0, tensy dit ingestel is) fco2 - relatiewe konsentrasie CO2 (0,004, tensy dit ingestel is) obsalt- observatoriumhoogte, in km teldiam- observatorium wat deursnee van die diafragma beperk, in m dx - horisontale verskuiwing van ster vanaf spleet sentrum dy - vertikale verrekening van ster vanaf spleet sentrum herhaling - of om baie diagnostiese inligting terug te gee, of net ligverlies.

ydisp - Die posisie van die spektrum in die gleuf

waardes van wobj. Dit moet 'n skikking van dieselfde grootte as wobj hê, met nul wat ooreenstem met die vertikale middel van die gleuf en positiewe waardes na die hoogtepunt neig. In hierdie geval sal xdisp bereken word as XXXX eerder as uit die berekende atmosferiese dispersie dx en dy sal ook geïgnoreer word.

fwhm - Volledige breedte by half-maksimum van die spektrale spoor, by

alle waardes van wobj. Dit moet 'n skikking van dieselfde grootte as wobj hê, gemeet in boogsekondes.

& # 8216slitwidth & # 8217, & # 8216slitheight & # 8217, & # 8216seeing & # 8217, & # 8216dx & # 8217, & # 8216dy & # 8217, and & # 8216fwhm & # 8217 (if used) should all be in the same units: arc seconds .

skikking: breukdeelverlies by elke golflengtewaarde

tuple van skikkings: (slitloss, disp_obj, diff, fwhm, dx_obj, dy_obj)

Alles insetgedrewe. Vir die SpeXTool-weergawe-analoog, sien ligte verlies ()

voer gevoelloos in soos np invoer spec w = np.linspace (.5, 2.5, 100) # Golflengte, in micron d2r = np.deg2rad (1.) #tarPA, za = spec.parangle (1.827, 29.67 * d2r, lat = 20. * d2r) targetPA, za = 105.3, 27.4 slitPA = 90. * d2r

spec.lightloss2 (w, 3., 15., slitPA, targetPA * d2r, za * d2r, 2.2, 1.0)

2003-10-21 - Geskryf deur W D Vacca 2011-10-07 20:19 IJMC: Omgeskakel na Python, aangepas vir enkele voorwerpe 2011-10-14 14:01 IJMC: Bygevoegde tjek vir Prisma-modus (het

verskillende sleuteldimensie sleutelwoorde) en verskillende pyfits-kopleesmodus.

2011-11-07 15:53 ​​IJMC: Bygevoeg & # 8216retall & # 8217 sleutelwoord 2011-11-07 21:17 IJMC: Gekanibaliseer vanaf SpeXTool weergawe 2011-11-25 15:06 IJMC: Bygevoegde opsies ydisp en fwhm.

Genereer 'n genormaliseerde Sky-raamwerk uit SpeX-spleetlose spektroskopiedata.

Lêername van skyframe sonder spektroskopie

middelpunt van die streek om die raam te mediaan-normaliseer.

volle breedte van die streek om te gebruik om die raam mediaan te normaliseer.

Stel toepaslike regstellingsraamwerke op vir multi-voorwerp-spektrograafdata. Spesifiek: regstellings vir onreëlmatige spleetwydtes en sensitiwiteitsvariasies tussen pixel-vir-pixel-detektor.

Meester spektrale lugraamwerk, bv. van mediaan-stapel baie lugraamwerke of masker-en-stapel gedifferensieerde wetenskapspektra-rame. Hierdie raam word gebruik om 'n kaart te konstrueer om wetenskaplike rame (geneem met dieselfde spleetmasker!) Reg te stel vir onreëlmatige lugagtergronde as gevolg van nie-eenvormige spleetwydtes (bv. Keck / MOSFIRE).

Let daarop dat die verspreidingsrigting & # 8216horizontaal & # 8217 (dws parallel met rye) in hierdie rame moet wees.

Meester koepel spektraal plat, bv. van mediaan-stapel baie koepel spektra. Dit hoef nie in die verspreiding of ruimtelike rigting genormaliseer te word nie. Hierdie raam word gebruik om 'n plat kaart van die pixel-tot-pixel-variasies in detector-sensitiwiteit op te stel.

Let daarop dat die verspreidingsrigting & # 8216horizontaal & # 8217 (dws parallel met rye) in hierdie rame moet wees.

subreg_corners: volgorde van 2- of 4-reekse Indekse (of bloot begin- en eindrye) vir elke substreek van belangstelling in & # 8216sky & # 8217 en & # 8216domeflat & # 8217 rame. Sintaksis moet die van wees tools.extractSubregion () , of sodanig dat subreg = sky [subreg_corners [0]: subreg_corners [1]] badpixelmask: 2D NumPy-skikking, of str Nonzero vir enige slegte pixels, hierdie sal geïnterpoleer word met behulp van nsdata.bfixpix () . xord_pix: volgorde van polinoomorde vir normalisering in verspreidingsrigting van pixelgebaseerde plat (koepel plat) op opeenvolgende iterasies sien makexflat () . xord_sky: volgorde van polinoomordes vir normalisering in verspreidingsrigting van spleetgebaseerde regstelling (lugraam) op opeenvolgende iterasies sien makexflat () . yord: skalaar Polinoomvolgorde vir normalisering van pixelgebaseerde (koepel) plat in ruimtelike rigting. locs: Geen, of volgorde Ry-indeks in elke substreek van die ligging van die spektrale belangstelling. Slegs gebruik om die lugraam reg te stel en dit op Geen te laat nie, het hoogstens 'n effense effek. Indien nie Geen nie, moet dieselfde lengte as subreg_corners hê. As subreg_corners [0] = [800, 950] dan kan locs [0] ingestel word op, byvoorbeeld, 75 as die spoor in die middel van die substreek lê.

Helperfunksie vir golflengteMatch () : genereer 'n skaal, interpolatiewe model van die sjabloon.

Maak 'n ruimtelike profiel vanuit 'n spektrum, gegewe die ligging daarvan. Ons interpoleer die PSF by elke pixel na 'n algemene verwysingsraamwerk en bereken dit dan.

lêernaam: str _OR_ 2D numy array 2D echellogram spoor: 1D numpy array stel polinoom koëffisiënte van orde (P-1) dispaxis: int set dispersie as: 0 = horisontaal en = vertikale fitwidth: int Totale breedte van onttrek spektraal subblok. Dit sal altyd verhoog word tot ten minste twee keer die grootste waarde van bkg_radii. neg: bool skalaar stel Waar vir 'n negatiewe spektrale spoor nsigma: skalaar Sigma-knipsel sny vir slegte pixels (verder as lees + foton geraas). Stel dit nogal hoog, en eksperimenteer gerus met hierdie parameter! xylims: 4-volgorde Onttrek die gegewe deelversameling van die data-skikking: [xmin, xmax, ymin, ymax] herhaling: bool Stel waar om verskeie addisionele parameters uit te voer (sien hieronder) rn: skalaar Lees ruis (elektrone) g: skalaar Detektorwins (elektrone per data-eenheid) bkg_radii: 2-volgorde Binneste en buitenste radius vir agtergrondberekening en -verwydering gemeet in pixels vanaf die middel van die profiel. bkg_order: int & gt 0 Polinome volgorde van agtergrondtendens bereken in meester-spektraalprofiel-interp: bool Of u elke sny (bi-lineêr) moet interpoleer om 'n presies-gesentreerde spektrale profiel te produseer (volgens die insette & # 8216spoor & # 8217). As dit onwaar is, sal snye slegs in lyn wees met die naaste pixel. UITVOER: as herhaling:

'n spline-funksie wat pixellokasies op die gemiddelde profiel interpoleer

ramings van die onsekerhede

anders: 'n splinefunksie wat pixelposisies interpoleer op die gemiddelde profiel spesifikasiemakexflat(subreg, xord, nsigma = 3, minsnr = 10, minfrac = 0,5, niter = 1) [bron] ¶

spektrale substreek, met spektrale agtergrond-, lug- en / of teikenstroommetings.

Orde van polinoom waardeur elke RY genormaliseer word. As niter & gt0, kan xord 'n volgorde van lengte wees (niter + 1). 'N Goeie benadering vir byvoorbeeld spectrale koepelvlakke is om niter = 1 en xord = [15,2] in te stel.

Sigma-knipvlak vir berekening van kolom vir kolom S / N

Minimum S / N-waarde om te gebruik as u & # 8216goed & # 8217 kolomme vir normalisering kies.

minfrac: skalaar, 0 & lt minfrac & lt 1

Fraksie van kolomme om te gebruik, gekies deur die hoogste S / N, wanneer u & # 8216goed & # 8217 kolomme kies vir normalisering.

Aantal iterasies. As dit op nul gestel is, moet dit nie herhaal nie (d.w.s. hardloop presies een keer deur)

Helperfunksie vir funksies XXXX

Vertoon vir eers 'n boodskap met teks.

Model 'n rou spektrumspoor!

LET WEL dat die meeste insette in die _gekorrigeerde_ raam moet wees.

Spoor agtergrond voetstuk vlak: 1D skikking

Breedte van die voetstukvlak in die agtergrond: skalaar (vir nou)

Spoorpunt: 1D-skikking

Verrekening van objekspektrum, relatief tot middelpunt: skalaar

breedte van 1D PSF: skalaar

Oppervlakte van 1D psf: 1D skikking

Vervorming (op een of ander manier x en y.)

Verspreide ligte agtergrond: skalaar (vir nou)

Model 'n spektrale resolusie-element.

param [0, 1, 2] - amplitude, sigma en sentrale ligging van die Gaussiese lynprofiel (vgl. analysis.gaussian () ).

param [3, 4, 5] - amplitude, breedte en sentrale ligging van agterhoedagtige agtergrond (vgl. keil() ).

param [6 ::] - addisionele (konstante of polinoom) agtergrondkomponente, vir evaluering met numpy.polyval ()

Waardes waarop modelfunksie (d.w.s. pixels) geëvalueer kan word. Tipies 1D.

model van die resolusie-element, met dieselfde vorm as x.

Model 'n spektrale resolusie-element in die ruimtelike rigting. Dit bestaan ​​uit 'n (vermoedelik Gaussiese) lynprofiel wat bo-op die spektrale spoor en top-hoedagtige agtergrond geplaas word, met 'n addisionele konstante (of polinoom) buite-egel-agtergrondkomponent.

Genereer 'n rotasieprofiel, draai dit saam met 'n tweede invoerprofiel, normaliseer dit (eenvoudig) en keer terug.

param [0: 3] & # 8211 sien rotationalProfile () param [4] & # 8211 vermenigvuldigende skaalfaktor

prof2: tweede invoerprofiel

Trek en normaliseer 'n spektroskopiese platveldraamwerk.

Meester, ongenormaliseerde plat raam: veronderstel dat dit gemeet word in foto-elektrone (vir rekenaaronsekerhede).

Aantal spektrale bestellings om te vind en te normaliseer

Minimum skeiding, in pixels, tussen spektrale bestellings wat gevind sal word.

Breedte van die kern van die mediaanfilter wat gebruik word om die lae-

Detector lees ruis in elektrone. Vir rekenaaronsekerhede.

badpixelmask: 2D NumPy-skikking

slegte pixelmasker: 1 op slegte pixel-plekke, 0 elders.

spore: 2D NumPy Array (noord, pord) gevormde verdoofde skikking wat die polinoom voorstel

koëffisiënte vir elke bestelling (geskik vir gebruik met np.polyval), soos vervaardig deur spoororde ()

Onttrek spektrum na Horne 1986.

Toepaslike gekalibreerde raam waaruit spektrum onttrek kan word. Moet in eenhede van ADU wees, nie elektrone nie!

Afwykings van pixelwaardes in & # 8216data & # 8217.

Detektorwins, in elektrone per ADU

Detector se geluidssterkte, in elektrone.

Is gelyk aan 0 vir slegte pixels, 1 vir goeie pixels

bkg_radii: 2- of 4-volgorde

As lengte 2: binneste en buitenste radiusse om in die agtergrond van die rekenaar te gebruik. Let daarop dat die spektraalspoor posisies in die middel van & # 8216data moet wees.

As lengte 4: begin- en eindindekse van beide diafragma's vir agtergrondpassing, van die vorm [b1_start, b1_end, b2_start, b2_end] waar b1 en b2 die twee agtergrondopeninge is, en die elemente in streng stygende volgorde gerangskik is.

extract_radius: int of 2-volgorde

radius om te gebruik vir sowel vloeinormalisering as onttrekking. As 'n ry, die eerste en laaste indeks van die skikking wat gebruik moet word vir spektral normalisering en ekstraksie.

0 vir horisontale spektrum, 1 vir vertikale spektrum

Graad polinome agtergrond pas.

Sigma-knipdrempel vir rekenaaragtergrond.

Graad polinoom geskik vir die konstruksie van profiel.

Sigma-knipdrempel vir rekenaarprofiel.

Sigma-knipdrempel vir skoonmaak en verwerping van kosmiese strale.

As dit waar is, maskeer alle nie-eindige waardes as slegte pixels.

Aantal pixels om in elke herhaling te verwerp.

[0] & # 8211 spektrumstroom (in elektrone)

[1] & # 8211 onsekerheid oor spektrumvloei

Horne se klassieke optimale onttrekkingsalgoritme is net optimaal, solank die spektrale spore byna in lyn is met detektorrye of -kolomme. dit is nie goed geskik vir die onttrekking van wesenlik gekantelde of geboë spore, om die redes beskryf deur Marsh 1989, Mukai 1990. Vir die ekstrahering van sulke spektra, sien superExtract () .

Voer optimale spektrale ekstraksie in IDL-slaagresultate na Python uit.

lêernaam, of 2D Numpy Array, of 'n lys met lêername wat rame bevat waaruit spektra gehaal sal word. Dit moet in eenhede van ADU wees (nie elektrone nie) sodat die geluidseienskappe behoorlik kan uitkom.

Die spektrale spoor moet ook vertikaal oor die raam loop.

Detektorwins, in elektrone / ADU

Detector lees ruis in elektrone

x1, x2: ints, of lyste van ints

Begin en stop indekse van die spektrale spoor oor die raam. As meerdere rame ingevoer word en 'n enkele x1 / x2 ingevoer word, sal dieselfde waarde vir elke raam gebruik word. Let egter daarop dat verskeie x1 / x2 ook ingevoer kan word (een vir elke raam).

Pad na die IDL-uitvoerbare program. OPTSPECEXTR.PRO en die gepaardgaande lêers moet in u IDL-pad wees. As ingestel op Geen, dan sal dit ingestel wees op: os.popen (& # 8216watter idl & # 8217). Lees (). Strook ()

Of u lêers moet oorskryf wanneer u invoerdata na TEMPFRAMFN skryf.

As invoer & # 8216raam & # 8217 'n skikking is, sal dit na hierdie lêernaam geskryf word om dit aan IDL oor te dra.

IDL sal die spektrale data na hierdie lêernaam skryf om dit weer aan Python oor te dra.

Lêernaam waarin die kort IDL-skrif geskryf sal word.

Opsies om na OPTSPECEXTR.PRO deur te gee. Byvoorbeeld: & # 8220adjfunc = & # 8217adjgauss & # 8217, adjoptions =, bgdeg = 3 & # 8221

Let daarop dat hierdie Python-kode sal breek as u die spektrum nie (aanpassings, ens.) Opspoor nie, dit is 'n area vir toekomstige werk as ek ooit 'n spektrograaf met reguit spore gebruik.

Naam van die goeie pixelmasker vir OPTSPECEXTR.PRO. Gelyk aan 1 vir goeie pixels, en 0 vir slegte pixels.

[0] & # 8211 Onttrek spektrum, ADU per pixel [1] & # 8211 Onsekerheid (1 sigma) van onttrek spektrum [2] & # 8211 Ligging van spoor (in pixels) oor die raam [3] & # 8211 Breedte van spoor oor die raam

Let daarop dat dit Horne et al. as doen optimalExtract () , en is vinniger as beide die funksie en (veral!) extractSpektralProfiele () . Die enigste nadeel (as dit een is) is dat hierdie funksie IDL benodig.

Voeg opsies by vir gebruikersinvoer van 'n afwykingsraamwerk of van lugafwyking.

Laat meer buigsaamheid toe (opsporing, invoer / uitvoer opsies, ens.)

  • NAAM:

    parangle

    DOEL:

    Om die parallaktiese hoek op 'n gegewe posisie in die lug te bereken.

    KATEGORIE:

    Spektroskopie

    OPROEPVOLG:

    eta, za = parangle (HA, DEC, lat)

    INSETTE:

    HA - Uurhoek van die voorwerp, in desimale uur (0,24) DEC - Afwyking van die voorwerp, in grade breed - Die breedtegraad van die waarnemer, in grade

    SLEUTELWOORDPARAMETERS:

    ANNULER - Stel terug as daar 'n probleem is

    UITSETTE:

    eta - Die parallaktiese hoek za - Die hoogtepunt van die hoogtepunt

    PROSEDURE:

    Gegewe die voorwerpe HA en DEC en die waarnemersbreedte, word die hoogtepunt van die hoogtepunt en die asimut bereken. Die wet van kosinusse gee dan die parallaktiese hoek.

    VOORBEELD:

    NA

    WYSIGINGSGESKIEDENIS:

    2000-04-05 - geskryf deur M. Cushing, Instituut vir Sterrekunde, UH 15-08-2002 - het 'n bietjie skoongemaak. 2003-10-21 - verander ook na pro-uitsette se hoogtepunt - WDV 2011-10-07 17:58 IJMC: Omgeskakel na Python

as: (as-voorbeeld) & # 8211 asse om 'n plek te kies

zoom: int & # 8211 zoomstraal vir teikenbevestiging

: 2-tuple & # 8211 (x, y) radiusse vir zoombevestiging.

Bereken die chi-kwadraatfout op 'n spektrum teenoor 'n profiel

Verander GMOS-rame wat met persoonlike ROI's geneem is in standaard FITS-rame.

Voer lêernaam of lêername in.

uit: tou of volgorde van snare

Voer lêernaam of lêername uit.

Word deurgegee aan PyFITS of bestaande lêers oorskryf moet word.

Hersien 'n spektrum met behoud van die vloeidigtheid.

nuwe golflengte rooster (dws die middel golflengte van elke pixel)

ou golflengte rooster (dws die middel golflengte van elke pixel)

ou spektrum (bv. vloeistofdigtheid of fotonetelling)

faktor waarmee die invoerspektrum oormonsters moet word voordat dit herbegin word. Die slegste presiese presisie wat u bereik, is ongeveer 1./overamp.

Formaat is dieselfde as numpy.interp ()

Bereken die rotasieprofiel van 'n ster, met die veronderstelling dat vaste liggaam rotasie en lineêre ledemaat verdonker.

Dit gebruik Vgl. 18.14 van Gray & # 8217 s Photospheres, 2005, 3de uitgawe.

[0]: delta_Lambda_L = lambda * V * sin (i) / c die rotasie

verplasing by die sterre ledemaat.

[1]: epsilon, die lineêre ledemaat verdonkeringskoëffisiënt, gebruik in

die verhouding I (theta) = I0 + epsilon * (cos (theta) - 1).

[2]: OPSIONEEL! Die sentrale ligging van die profiel (andersins

word aanvaar dat dit geleë is by delta_lam = 0).

Golflengte minus verrekening: Lambda minus lambda_0. Rooster waarop berekeninge gedoen sal word.

Begin LBLRTM om atmosferiese deurlaatbaarheid en / of straling te bereken.

benaderde minimum en maksimum golflengtes

mm neerslagbare waterdamp bo waarnemingsterrein. As dit negatief is, word die waarde abs (pwv_offset-pwv) eerder gebruik.

Word slegs gebruik as (pwv & lt 0) hierbo sien vir beskrywing.

waarnemingshoek vanaf hoogtepunt, in grade

Waarnemingshoogte, in km.

CO2-konsentrasie in dpm per volume. Daar word aanvaar dat konsentrasie in die atmosfeer eenvormig is.

benaderde spektrale resolusie verlang

atmosferiese transmissie te bereken

atmosferiese straling te bereken. WERK NIE TANS NIE

pad waar tydelike MAT-lêer gestoor sal word

pad waar MATLAB-omhulselskrifte vir LBLRTM geleë is

lêernaam vir tydelike MATLAB / OCTAVE-skrif (gestoor na uitgang)

pad na MATLAB / OCTAVE uitvoerbare

'N 2- of 3-tupel: Eerste element is golflengte in mikron, tweede element is transmissie (indien versoek). Straling sal (indien versoek) altyd die laaste element wees, en in f_nu eenhede: W / cm2 / sr / (cm ^ -1)

Gebruik kruiskorrelasie om skuins agtergronde in die skuins lug af te trek.

subframe: NumPy array data subframe met sky data wat afgetrek moet word (en, miskien, 'n voorwerp en spektrale spoor). badpixelmask: Geen of NumPy-skikking 'n Booleaanse skikking, gelyk aan nul vir goeie pixels en eenheid vir slegte pixels. As dit ingestel is, is die eerste stap 'n oproep na nsdata.bfixpix () om hierdie waardes te interpoleer. nmed: die grootte van die 2D mediaanfilter vir die gladstryking. pord: int graad van spektraal kantel. Hou hierdie getal laag! maxshift: int Maksimum aanvaarbare skof. NOG NIE INGEVOER NIE! fitwidth: int Maksimum radius (in pixels) om aan te pas by die kruin van die kruiskorrelasie. nmed: int Grootte van die venster vir die 2D-mediaanfilter (om slegte pixels te verwerp, ens.) dispaxis: int stel die verspreidingsas: 0 = horisontaal en 1 = vertikale ruimtelike_indeks: geen, of 1D NumPy-skikking van die tipe bool Watter ruimtelike rye (indien dispaxis = 0) gebruik om die skuins van luglyne oor die spektrum te pas? As u alles wil gebruik, stel dit in op Geen. As u sommige wil ignoreer (bv. Omdat daar 'n helder voorwerp is en die spektrum daar is), stel dan die rye & # 8217; elemente van ruimtelike_indeks in op & # 8216Fals & # 8217. refpix: skalaar Pixel langs die ruimtelike as waarop die spektrale pas in lyn moet wees as daar 'n spektraalspoor is, moet 'n mens & # 8220refpix & # 8221 op die plek van die spoor stel. tord: int Orde van polinoom pas langs die ruimtelike rigting in 'n belynde 2D-spektrale raam, om rekenskap te gee van onregmatige of onregmatige kantelrigting.

RETOURS:
RETOURS:'n model van die lugagtergrond, van dieselfde vorm as & # 8216subframe. & # 8217
spesifikasiescaleSpectralSky_dsa(onderraam, variansie = Geen, badpixelmask = Geen, nk = 31, pord = 1, nmed = 3, wins = 3.3, leesgeraas = 30, dispaxis = 0, spatial_index = Geen) [bron] ¶

Gebruik tegnieke om verskillende beeldvormings te vorm om matige skuins agtergrond van die lug af te trek. Werk nie so goed nie!

subframe: NumPy array data subframe met sky data wat afgetrek moet word (en, miskien, 'n voorwerp en spektrale spoor). Veronderstel om in ADU te wees, nie elektrone (sien versterking en leesnoise) afwyking: Geen of NumPy skikkingafwyking van elke pixel in & # 8216subframe & # 8217 nmed: int grootte van 2D mediaan filter pord: int graad van spektraal kantel. Hou hierdie getal laag! nk: int Aantal kernpixels in dia.dsa () nmed: int Grootte van venster vir 2D mediaanfilter (om slegte pixels te verwerp, ens.) dispaxis: int stel dispersie-as: 0 = horisontaal en 1 = vertikale versterking, leesgeluid: inte As & # 8216variansie & # 8217 is Geen, word hierdie gebruik om die onsekerhede te skat. spatial_index: None, of 1D NumPy-skikking van die tipe bool Watter ruimtelike rye (as dispaxis = 0) gebruik om die skuins van skylyne oor die spektrum te pas. As u alles wil gebruik, stel dit in op Geen. As u sommige wil ignoreer (bv. Omdat daar 'n helder voorwerp is en die spektrum daar is), stel dan die rye & # 8217; elemente van ruimtelike_indeks in op & # 8216Fals & # 8217.

OPMERKINGS:Let daarop dat (in my ervaring!) Hierdie benadering beter werk as u alle gewigte op eenheid stel, eerder as om die voorgestelde (foton + leesgeruis) afwykings te gebruik.

Wys die beste pas-lugraamwerk.

Gebruik PCA en leë lugraamwerke om af te trek

raam: str of NumPy skikking dataraam om lug van af te trek. Veronderstel dat dit in ADU is, nie elektrone nie (sien versterking en leesstof) npca: die aantal PCA-komponente om te verwyder

f0 = pyfits.getdata (odome.procsci [0]) masker = pyfits.getdata (odome._proc + & # 8216skyframes_samplemask.fits & # 8217) .astype (bool) badpixelmask = pyfits.getdata (odome.badpixelmask) .astype (bool )

Die eenvoudigste manier om 'n lug in 'n & # 8216-raam & # 8217 die kleinste vierkante pas).

Oorweeg dit om verskeie kere te hardloop (een keer per bestelling) om dit vir multi-voorwerpdata te gebruik

Wys die beste pas-lugraamwerk soos bepaal uit die eerste & # 8216npca & # 8217 PCA-komponente.

Bereken vloed wat deur 'n gleuf gaan, met die veronderstelling dat 'n gaussiese PSF.

breedte - Breedte van die gleuf. hoogte - Hoogte van die gleuf. fwhm - Volledige breedte by die helfte van die maksimum van die Gaussiese beeld. xoffset - Offset in x van die beeld vanaf die middel van die gleuf. yoffset - Offset in y van die beeld vanaf die middel van die gleuf.

Opmerking: die eenhede is arbitrêr, maar hulle moet dieselfde wees

al die invoerhoeveelhede.

Bereken die fraksie van die vloed wat deur 'n gleuf 0,3x15 boogsekondes oorgedra word met 'n PSF van 0,6 boogsekondes FWHM. Die PSF is op die gleuf gesentreer.

Gebaseer op M Buie-program, 1991 Maart, Marc W. Buie, Lowell Observatory Gewysig 2000 Apr., M. Cushing om y verrekenings in te sluit. 2011-10-07 15:45 IJMC: Omgeskakel na Python 2011-11-14 16:29 IJMC: Herskryf om te gebruik erf () eerder as

Los verspreide lig in SpeX / SXD K-band en skryf 'n nuwe lêer.

nuwe lêernaam van die vaste lêer.

of u bestaande FITS-lêers moet oorskryf

0 as 'n probleem is, 1 as alles reg is

Model die verspreide lig gesien in SpeX / SXD K-band rame.

lêernaam van die rou SXD-raam wat moet reggestel word, of 'n Numpy-skikking wat sy data bevat.

halfbreedte van die spektrale orde. Die ervaring toon dat dit ongeveer 48 pixels is. Hierdie waarde is nie geskik nie!

minimum en maksimum x-pixel waardes om in die passtuk te gebruik

minimum en maksimum y-pixelwaardes om in die passtuk te gebruik

of u slegs die model of die tuple moet uitvoer (model, pas, chisq, nbad)

integrasietyd, in sekondes, waarmee die aanvanklike raaiskote geskaal kan word

scatter_model: gevoelloos skikking

Model van die verstrooide ligkomponent vir aftrekking of besparing.

scatter_model, past, chis, nbad

I could stand to be more clever in modeling the scattered light components – perhaps fitting for the width, or at least allowing the width to be non-integer.

Extract a spectrum from a frame using one of several methods.

Contains a single spectral trace.

Gain of data contained in ‘frame’ i.e., number of collected photoelectrons equals frame * gain.

readnoise : None or scalar

Read noise of detector, in electrons.

framevar : None, 2D Numpy array, or filename

Variance of values in ‘frame.’

If and only if framevar is None, use gain and readnoise to compute variance.

badpixelmask : None, 2D Numpy array, or filename

Mask of bad pixels in ‘frame.’ Bad pixels are set to 1, good pixels are set to 0.

Which spectral extraction mode to use. Options are:

Spectral trace location: fractional pixel index along the entire spectral trace. If None, traceorders() will be called using the options in ‘trace_options.’

Keyword options to be passed to the appropriate spectral extraction algorithm. Note that you should be able to pass the same sets of parameters to superExtract() and optimalExtract() (the necessary parameter sets overlap, but are not identical).

trace_options : None or dict

Keyword options to be passed to traceorders() (if no trace is input, or if mode=’spline’)

spectrum, error or variance of spectrum, sky background, .

When ‘optimalextract’ is used: if len(bkg_radii)==2 then the background apertures will be reset based on the median location of the trace. If extract_radius is a singleton, it will be similarly redefined.

Optimally extract curved spectra, following Marsh 1989.

Appropriately calibrated frame from which to extract spectrum. Should be in units of ADU, not electrons!

Variances of pixel values in ‘data’.

Detector gain, in electrons per ADU

Detector readnoise, in electrons.

location of spectral trace. If None, traceorders() is invoked.

goodpixelmask : 2D numpy array

Equals 0 for bad pixels, 1 for good pixels

Number of profile polynomials to evaluate (Marsh’s “K”). Ideally you should not need to set this – instead, play with ‘polyspacing’ and ‘extract_radius.’ For symmetry, this should be odd.

Spacing between profile polynomials, in pixels. (Marsh’s “S”). A few cursory tests suggests that the extraction precision (in the high S/N case) scales as S^-2 – but the code slows down as S^2.

Order of profile polynomials 1 = linear, etc.

inner and outer radii to use in computing background

radius to use for both flux normalization and extraction

0 for horizontal spectrum, 1 for vertical spectrum

Degree of polynomial background fit.

Sigma-clipping threshold for computing background.

Degree of spectral-trace polynomial (for trace across frame – not used if ‘trace’ is input)

Sigma-clipping threshold for cleaning & cosmic-ray rejection.

If true, mask all non-finite values as bad pixels.

How to compute Marsh’s Q-matrix. Valid inputs are ‘fast-linear’, ‘slow-linear’, ‘fast-nearest,’ ‘slow-nearest,’ and ‘brute’. These select between various methods of integrating the nearest-neighbor or linear interpolation schemes as described by Marsh the ‘linear’ methods are preferred for accuracy. Use ‘slow’ if you are running out of memory when using the ‘fast’ array-based methods. ‘Brute’ is both slow and inaccurate, and should not be used.

Number of outlier-pixels to reject at each iteration.

If true, also return the 2D profile, background, variance map, and bad pixel mask.

Iterate background fitting and reject outliers maybe first time would be unweighted for robustness.

Introduce even more array-based, rather than loop-based, calculations. For large spectra computing the C-matrix takes the most time this should be optimized somehow.

Grey-pixel tophat function with set width param: [cen_pix, amplitude, background] newparam: [amplitude, full width, cen_pix, background] x : must be array of ints, arange(0, size-1) returns the model.

Standard tophat function (alternative version).

p[0] – Amplitude p[1] – full width dispersion p[2] – central offset (mean location) p[3] – vertical offset (OPTIONAL)

values at which to evaluate function

1.0 where |x| < 0.5, 0.5 where |x| = 0.5, 0.0 otherwise.

Trace spectral orders for a specified filename.

filename : str OR 2D array full path and filename to a 2D echelleogram FITS file, _OR_ a 2D numpy array representing such a file.

OPTIONAL INPUTS: pord : int

full path and filename to a 2D uncertainties FITS file, _OR_ a 2D numpy array representing such a file.

If this is set, ‘g’ and ‘rn’ below are ignored. This is useful if, e.g., you are analyzing data which have already been sky-subtracted, nodded on slit, or otherwise altered. But note that this must be the same size as the input data!

g : scalar > 0 Detector gain, electrons per ADU (for setting uncertainties) rn : scalar > 0 Detector read noise, electrons (for setting uncertainties) retsnr : bool If true, also return the computed S/N of the position fit at each stepped location. retfits : bool If true, also return the X,Y positions at each stepped location.

RETURNS: (nord, pord) shaped numpy array representing the polynomial

coefficients for each order (suitable for use with np.polyval)

If tracing fails, a common reason can be that fitwidth is too small. Try increasing it!

Determine dispersion solution for a spectrum, from a template.

Spectrum for which a wavelength solution is desired.

Known wavelength grid of a template spectrum.

Flux (e.g.) levels of the template spectrum with known wavelength solution.

Uncertainties on the template values. This can be important in a weighted fit!

Initial guess for the wavelength solution. This is very helpful, if you have it! The guess should be a sequence containing the set of Chebychev polynomial coefficients, followed by a scale factor and DC offset (to help in scaling the template).

If guess is None, attempt to fit a simple linear dispersion relation.

NOT YET IMPLEMENTED! BUT EVENTUALLY: if guess is None, this sets the polynomial order of the wavelength solution.

FOR THE MOMENT: if guess is None, return a simple linear solution. This is likely to fail entirely for strongly nonlinear dispersion solutions or poorly mismatched template and spectrum.

Number of processors to use for MCMC searching.

(wavelength, wavelength_polynomial_coefficients, full_parameter_set)

This implementation uses a rather crude MCMC sampling approach to sample parameters space and ‘home in’ on better solutions. There is probably a way to do this that is both faster and more optimal.

Note that if ‘spectrum’ and ‘template’ are of different lengths, the longer one will be trimmed at the end to make the lengths match.

Compute zenith angle (in degrees) for an observation.

Right Ascension of target, in format: HH:MM:SS.SS

Declination of target, in format: +ddd:mm:ss

Hour Angle of target, in format: +HH:MM:SS.SS

Name of observatory site (keck, irtf, lick, lapalma, ctio, andersonmesa, mtgraham, kpno) or a 3-tuple containing (longitude_string, latitude_string, elevation_in_meters)


How do you create a continuum mask in Python or IDL for a star? - Sterrekunde

IRTF and General Reduction Tools

This repository contains some IRAF scripts and IDL scripts for viewing and processing spectrograph and image files. It includes a pipeline for reducing IRTF SpeX prism data in time series modes. The IRTF SpeX prism data should have 2 sources - a target and reference star that are imaged on the slit simultaneously. The pipeline is designed to work with data taken with the 3x60'' slit. The pipeline will take raw data and apply the following:

  • Correct linearity, trim data
  • Apply flat and dark corrections
  • Shift images to account for pointing errors
  • Rectify the spectra
  • Correct for bad pixels
  • Extract spectral with optimal extraction techniques. This refereed paper describes the pipeline: http://adsabs.harvard.edu/abs/2014ApJ. 783. 5S

There is a hefty list of code requirements for this pipeline. Be prepared that installing all these pieces may take a long time unless you already have experience with them.

My preferred way to add to the IDL path is to edit my .bash_profile :

where path1 is to the The IDL Astronomy User's Library, path2 is to E Schlawin's IDL Routines and path3 is the directory containing this code repository.

These are intended as reminders to oneself and not a complete set of instructions for a new user.

  • Put all data into a directory called edited - this will contain a duplicate of all raw data
  • All data files should be called run*.fits (it’s OK if they’re sky images called runsky*.fits )
  • All flat images (with relevant 3x60 slit) should be flat*.fits
  • All dark images should be dark*.fits
  • All arc images (only the 0.3 x 60 slit) should be arc*.fits
  • All sky files (if using) should be listed in sky_choices.txt
  • Get rid of all periods except for the ending of files may be file.a.fits or file.b.fits
  • Remove all files not explicitly described in this list
  • Make a proc directory adjacent to the edited folder
  • You may have to modify permissions to the fits files (for example, the files may be set to read-only). This can be accomplished with chmod 755 *
  • The python script prep_SpeX_images.py , can help with the above tasks.

B: Load the necessary NOAO procedures

where /data/OBJECT5/bigdog/ is the location of the IRTF SpeX prism spectrograph data. You may get a warning with my IRAF about camera.dat. A solution is available here: http://iraf.net/forum/viewtopic.php?showtopic=1467939

These can also be placed in the login.cl file so they are loaded with each log-in.

where path_to_reduction_scripts is the path to this repository.

D: Reduce data from the “edited” directory

The reduction steps will apply linearity corrections (optional), flat fields, bad pixel masks, dark subtractions and accounts for flexure of the telescope, which causes the spectra and background to shift positions.

  • Navigate to the edited directory which contains a copy of all relevant raw files. Edit the local_red_params.cl file to have the correct parameters for your file.
    • You will need to set a trim region the default is s1 = "[65:749,33:607]" . However, you should make sure that the trim is the largest region that clips out all un-illuminated rows of the detector.
    • Open the image to locate the sources. Make sure that the background box and background spectrum region are between the two sources. X,Y coordinates are from the bottom left corner. The #ESParam backbox [X1:X2,Y1:Y2] line should have X1 and X2 encompassing the H band background emission and the Y1 and Y2 values should be between the two sources.
    • If you have local b1 = yes , it will use the sky flats. You’ll need to select a set of sky images to combine (called sky_choices.txt ). You can also have optional mask_for_runsky005.fits files to specify where to mask out sources. If you are not using sky flats, set b1 = no . For first time use, it is simpler to have b1 = no and do the sky flats on another pipeline run.

    E: Initial Spectral Extraction

    This step will rectify the images, extract spectra from each source, do background subtraction. It first uses the IRAF apall routines, but then can be run again with custom optimal extraction techniques. The resulting files are FITS images with flux and background as function of wavelength for each star.

    Navigate to the proc directory.

    Start by going through the images in the middle of the time series to be used as a reference aperture-finding. Select an image with few artifacts, cosmic rays or star-like blemishes due to alpha particles from a Th-containing coating on the optics. After choosing the reference image, write the name of it to a file with ls run_image_spc_00187.a.fits > ap_reference.txt where in this example it is image 187.

    Next create a local_extract_params.cl file where you will set the distance range between the sources and background fitting parameters (polynomial order). You can copy a previous file, but will need to be sure that the distance range between the source apertures includes the true value.

    The Argon line identification is a very tedious process. It is easier to start by copying the Wavelength ID file from a previous extraction.

    /reduction_code/ is the path to this repository.

    Load in the extraction parameters with cl < local_extract_parameters.cl

    Create an initial IRAF extractions on the data by running extraction_script

    If the first time running, edit the identification file so that the coefficients for Aperture 1 and Aperture 2 are identical and run again: emacs database/idfirst_wavecal

    If at any time you need to re-run the extraction, first run reset_extraction to wipe the previously created files.

    A useful map of the wavelength identification is included in example_params/labeled_argon_lines_nist.png

    F: Run the custom IDL extraction routine with:

    This step has IDL routines to do optimal extraction and also gives more control over the background subtraction process.

    Navigate to the proc directory

    Make and edit a es_local_parameters.txt . For exampe cp

    /reduction_code/example_params/es_local_parameters.txt . The name must be exactly es_local_parameters.txt . In many cases the default parameters will be OK. You may need to adjust the size of the background aperture size ( BackSize ) if the sources are close.

    Run the backsub command from idl

    One can run es_backsub,/saveSteps to save the individual steps and view background-subtracted fits images to test the residuals. Since this multiplies the amount of data by the number of steps, it only runs on 10 images by default.

    Also, if the wavelength identification is updated, one may run redo_wavecal without re-extracting.

    Error in image section specification - usually it happens when I haven’t loaded the local parameters in (either cl < local_red_parameters.cl in the “edited” directory or cl < local_parameters.cl in the “processed” directory).

    Cannot find sky_choices.txt - didn't make a sky choices file

    You get the following error in ev_backsub :

    This could be that the aperture finding failed. You may notice that after extraction_script , you see something like Trace of aperture 1 in run_2017A013_170704_spc_00281.a lost at column 388. Try choosing another aperture reference file, as described in Section E. Also, make sure that nfind=2 when running epar apall

    ERROR: run_2017A013_170704_spc_00167.a.ms.fits - Missing reference for aperture 3 . It may have found 3 apertures instead of 2. Try choosing another aperture reference file, as described in Section E. Also, make sure that nfind=2 when running epar apall

    ERROR: HDMGETR: No value found "sample="*", naverage=1, nit . This may arise if you have not run adjust_headers first.

    ERROR: No images to combine line 17: reduction_script.cl . No darks were found. Probably the wrong indices in the pre-processing python script.

    ERROR: No write permission on file (String_File) . Double check that the ap_reference.txt file is OK. This happened when I accidentally set ap_reference to be a copy of the FITS file rather than the name of it.

    Multi-image viewer can aid in glancing through files, doing photometry etc.

    Type mphot to do photometry by clicking stars. It will ask you for a box search size in pixels. Create a file in the same directory that miv is run in called phot_params.txt . It should have the following format:


    Plotting a velocity field and creating your own masks

    We will now follow a similar procedure as above for the H&alpha but now for a velocity field.

    First we need to read in the velocity extension and H&alpha channel.

    Let's now make a signal-to-noise cut, so only the H&alpha velocities with a decent signal-to-noise are shown. For this we will use the inverse variance (ivar) extension.

    An important note regarding gas velocity fields: The velocities of the emission lines are tied together, so for example, the velocity of the [OIII]-5007 line is the same as the H&alpha line, as are the uncertainties. You cannot reduce the uncertainty on the measured velocity by averaging the velocities of several lines together.


    ROI-Based Processing

    A region of interest (ROI) is a portion of an image that you want to filter or operate on in some way. The toolbox supports a set of ROI objects that you can use to create ROIs of many shapes, such circles, ellipses, polygons, rectangles, and hand-drawn shapes. After creation, you can use ROI object properties to customize their appearance and functioning. In addition, the ROI objects support object functions and events that you can use to implement interactive behavior. For example, using events, your application can execute custom code whenever the ROI changes position. As a convenience, the toolbox includes a parallel set of convenience functions for ROI creation. For example, to create a rectangular ROI, you can use images.roi.Rectangle or the corresponding convenience function drawrectangle . For more information about ROIs, see ROI Creation Overview.

    A common use of an ROI is to create a binary mask image. In the mask image, pixels that belong to the ROI are set to 1 and pixels outside the ROI are set to 0 . To create a mask, use the createMask object functions supported by most of the ROI objects. You can also create a mask without requiring an image using the poly2mask function.

    Starting in R2018b, a new set of ROI objects replaced the previous set of ROI objects. The new objects provide better performance and more functional capabilities, such as face color transparency. With the new objects, you can also receive notification of interactions with the object, such as clicks or movement, using events. Although there are no plans to remove the old ROI objects at this time, switch to the new ROIs to take advantage of the additional capabilities and flexibility. For more information on migrating to the new ROIs, see ROI Migration.


    How do you create a continuum mask in Python or IDL for a star? - Sterrekunde

    Keck OSIRIS Data Reduction Pipeline

    • New wavelength solution for 2021. OSIRIS had to be opened for servicing in Dec. 2020, so new arc scans were taken in Jan 2021 and new wavelength solutions were created. Tests show that the average wavelength shift at Kn3 35 mas to be about -0.04+-0.07 Angstroms (based on comparisons with OH skylines). At Kn3 50 mas, the shift is on average: 0.38+-0.06 Angstroms.

    Release Notes for v5.0beta

    • New wavelength solution for 2019 & 2020. Unlike data before 2019, there appears to be larger residual offsets in the wavelength solution between different plate scales. The smallest shift is at 50 mas and the grows larger for smaller plate scales. At Kn3 35 mas, the offset is about 0.3 Angstrom based on comparisons with OH sky lines.
    • Handle imager upgrade pixel units (DN) instead of DN/s
    • The FITS files from the imager upgrade were flipped such that the images were not in an astronomical orientation.
    • QL2 will now flip IMAGER images about the x-axis (IDL-> im=reverse(im,2)) for upgraded images only. SPEC and DRP cubes are NOT flipped.
    • Made a slight update to IDL_astro routine xy2ad.pro to handle WCS in OSIMG images.
    • Other minor updates

    2018-05-07 Major Updates

    • Derived new wavelength solution for OSIRIS in March 2018, which was required because OSIRIS was opened. All users are recommended to use this version, especially those with data post March 2018.
    • Updated manual - new installation instructions, wavelength solution, bad pixel mask info, updated information post-2016 detector upgrade are ongoing. Download here

    2017-11-07 Major Updates

    • Includes a new wavelength solution for data after May 2017. A shift in the wavelength solution (on average about 2.8 Angstroms offset) in May 2017 required a re-derivation of the solution. The new solution has an average offset between the observed and vacuum wavelength of OH lines of 0.07 +- 0.06 Angstroms in Kn3 35 mas.
    • A preliminary bad pixel mask is available for data taken after 2016 (new spectrograph detector). The mask was computed from a series of darks. There is both a bad pixel mask of hot pixels (pixels with permanently elevated value) as well as a dead pixel mask (pixels with permanently low values). This mask meant to be used as extension 2 in the raw fits files. Currently, the mask is not automatically applied by Keck. To apply it, use the following command in the raw spectra directory once the pipeline is installed:

    NOTE: this requires python installed with numpy and astropy packages. Tests show that using the bad pixel mask improves the SNR by about 10%.

    • A new keyword is available in the Scaled Sky Subtraction module called scale_fitted_lines_only . To turn on the new behavior, the keyword should be set to YES and the Scale_K_Continuum should be set to NO:

    This keyword will only scale only OH lines, not the rest of the spectrum as well. This setting greatly improves sky subtraction for the case where the science target fills the lenslets and there are no true sky locations. It may also help in other cases. Users are encouraged to try this option if they see large residuals in sky subtraction, or if the residual continuum is problematic.

    • The cosmic ray module is now automatically turned off for all data with the new detector (see reasoning below). Cosmic rays represent about 1% of the bad pixels in a typical 15 minute exposure -- the majority are static bad pixels that should now be accounted for by the bad pixel mask.
    • Updates to the code in order to run the pipeline for the new detector (2016 data and newer).
    • Installation has now been simplified (see below for install directions). Bash scripts have been included for those who would like to use bash shell.
    • Test framework is now available to run tests of the pipeline (requires pytest module in python, see README in ''tests'' directory)
    • Optimized algorithms for the construction of data cubes
    • qlook2, odrfgui, and oopgui are now also included in the repository
    • WCS bugs have been fixed.
    • qlook2 fixes
      • units bug is fixed
      • fix initial autoscale to imager display
      • clean up startup scripts

      Cosmic Ray Module

      • We do not recommend running the cosmic ray module on data in 2016 or later, as it will introduce significant artifacts and reduce overall signal to noise. This is due to the fact that unresolved emission lines such as OH lines are now sharper on the detector. The cosmic ray module will tend to interpret this as a cosmic ray. To remove cosmic rays, we recommend combining data with the mosaic module with the MEANCLIP keyword if there are sufficient number of frames.
      • The cosmic ray module may lead to artifacts in data before 2016 as well, but at a lesser level. We recommend checking on individual science cases.
      • The pipeline team is investigating different cosmic ray modules for a future release.
      • More information is available in Issue 49 or in the wiki.

      Bad pixel mask A preliminary bad pixel mask is available for data taken after 2016 (new spectrograph detector). The mask was computed from a series of darks. There is both a bad pixel mask of hot pixels (pixels with permanently elevated value) as well as a dead pixel mask (pixels with permanently low values). This mask meant to be used as extension 2 in the raw fits files. Currently, the mask is not automatically applied by Keck. To apply it, use the following command in the raw spectra directory once the pipeline is installed:

      NOTE: this requires python installed with numpy and astropy packages. Tests show that using the bad pixel mask improves the SNR by about 10%.

      Old Modules

      • For data taken in 2016 onward, it is no longer necessary to run the following modules: Remove Cross Talk, Glitch Identification. It is fine to keep them in the DRF XML, these modules will automatically not run on the new data.

      Current Important OSIRIS Issues

      • For certain cases, there are flux artifacts: Issue 20, wiki link
      • Spatial rippling is seen in the integrate flux of sky lines spatially across the field: Issue 21 on these and other issues from the most recent OSIRIS Hackathon

      Please cite Lyke et al. (2017) and Lockhart et al. (2019) if you use this pipeline in a publication.

      To install and run the OSIRIS DRP, you will need the following:

      • A working C compiler (e.g. gcc )
      • A copy of the compiled library cfitsio
      • A working installation of IDL 7 or IDL 8 (the IDL binary directory should be in your PATH environment variable)
      • Python dependencies (optional, for testing): pytest, astropy

      Either clone or download the source from github, choose either the master branch or the develop branch.

      Set up the following environment variables to compile the code (you can remove these variables after compiling). The defaults should work for installations of IDL on Mac OS X and CFITSIO installed using MacPorts:

      • IDL_INCLUDE : The IDL include directory. If you don't set IDL_INCLUDE , it defaults to IDL_INCLUDE=/Applications/exelis/idl/external/include
      • CFITSIOLIBDIR : The directory containing your installation of CFITSIO. If you don't set CFITSIOLIBDIR , it will default to CFITSIOLIBDIR=/opt/local/lib , which is correct for MacPorts.

      Run the makefile from the top level of the OSIRIS DRP source code:

      You should see that the pipeline has been built correctly. Be sure you are using gmake (which on OS X is the only make , so using make works.)

      Setup OSIRIS DRP Runtime Environment

      The OSIRIS DRP requires various environment variables to find and run the pipeline. Instructions are below for bash (should work for other POSIX compliant shells) and c-shell. If you want to set up your environment every time you start your shell (e.g. via .cshrc or .bashrc ), you can add the environment variable, OSIRIS_VERBOSE=0 to silence the output of the setup scripts. Otherwise, they will print useful messages about the setup of your OSIRIS pipeline environment.

      Environment Setup in Bash

      You can add these lines to your .bashrc file or other startup profile if you want to set up the osiris environment variables for all of your shell sessions. Add these lines to your profile:

      Remember if your IDL binary is not in your path, you should also add it to your .bashrc file, for example:

      You can add these lines to your .cshrc file or other startup profile if you want to set up the osiris environment variables for each of your shell sessions. Add these lines to your profile:

      Remember if your IDL binary is not in your path, you should also add it to your .cshrc file, for example:

      To run the pipeline, use run_odrp . If you don't want the pipeline to open a new xterm window, call run_odrp -n .

      To run the suite of tests on the pipeline, and you have pytest and astropy in your python environment:

      The first time you run the tests, data will be downloaded so it will take longer. If the tests pass, your pipeline is installed properly. You will see something like the following if the tests pass:

      To set the default directories for the guis, you can edit the following two files:

      If you run into problems, please re-read this README.md, then read INSTALLPROBLEMS.md for some common installation problems.

      OSIRIS DRP Project Contributors

      Alphabetical list of contributors

      • Anna Boehle (@aboehle)
      • Randy Campbell
      • Sam Chappell
      • Devin Chu
      • Mike Fitzgerald (@astrofitz)
      • Tom Gasawy
      • Christof Iserlohe
      • Alfred Krabbe
      • James Larkin
      • Jim Lyke (@jlyke-keck)
      • Kelly Lockhart
      • Jessica Lu
      • Etsuko Mieda
      • Mike McElwain
      • Marshall Perrin
      • Alex Rudy (@alexrudy)
      • Breann Sitarski
      • Andrey Vayner
      • Greg Walth
      • Jason Weiss
      • Tommer Wizanski
      • Shelley Wright

      (If you have contributed to the OSIRIS pipeline and your name is missing, please send an email to the coordinators, or If you have contributed to the OSIRIS pipeline and your name is missing, please send an email to the coordinators, or open a pull request for this page in the OsirisDRP repository


      Gaussfitter¶

      agpy.gaussfitter.collapse_gaussfit(cube, xax=None, axis=2, negamp=False, usemoments=True, nsigcut=1.0, mppsigcut=1.0, return_errors=False, **kwargs) [source] ¶ agpy.gaussfitter.gaussfit(data, err=None, params=(), autoderiv=True, return_all=False, circle=False, fixed=array([False, False, False, False, False, False, False], dtype=bool), limitedmin=[False, False, False, False, True, True, True], limitedmax=[False, False, False, False, False, False, True], usemoment=array([], dtype=bool), minpars=array([0, 0, 0, 0, 0, 0, 0]), maxpars=[0, 0, 0, 0, 0, 0, 360], rotate=1, vheight=1, quiet=True, returnmp=False, returnfitimage=False, **kwargs) [source] ¶

      Gaussian fitter with the ability to fit a variety of different forms of 2-dimensional gaussian.

      data - 2-dimensional data array err=None - error array with same size as data array params=[] - initial input parameters for Gaussian function.

      returnfitimage - returns (best fit params,best fit image) returnmp - returns the full mpfit struct circle=0 - default is an elliptical gaussian (different x, y widths),

      Warning: Does NOT necessarily output a rotation angle between 0 and 360 degrees.

      Returns (height, amplitude, x, y, width_x, width_y, rotation angle) the gaussian parameters of a 2D distribution by calculating its moments. Depending on the input parameters, will only output a subset of the above.

      If using masked arrays, pass estimator=numpy.ma.median

      agpy.gaussfitter.multigaussfit(xax, data, ngauss=1, err=None, params=[1, 0, 1], fixed=[False, False, False], limitedmin=[False, False, True], limitedmax=[False, False, False], minpars=[0, 0, 0], maxpars=[0, 0, 0], quiet=True, shh=True, veryverbose=False) [source] ¶

      An improvement on onedgaussfit. Lets you fit multiple gaussians.

      These parameters need to have length = 3*ngauss. If ngauss > 1 and length = 3, they will be replicated ngauss times, otherwise they will be reset to defaults:

      params - Fit parameters: [amplitude, offset, width] * ngauss If len(params) % 3 == 0, ngauss will be set to len(params) / 3

      fixed - Is parameter fixed? limitedmin/minpars - set lower limits on each parameter (default: width>0) limitedmax/maxpars - set upper limits on each parameter

      quiet - should MPFIT output each iteration? shh - output final parameters?

      Returns a function that sums over N gaussians, where N is the length of a,dx,sigma OR N = len(pars) / 3

      The background “height” is assumed to be zero (you must “baseline” your spectrum before fitting)

      pars - a list with len(pars) = 3n, assuming a,dx,sigma repeated dx - offset (velocity center) values sigma - line widths a - amplitudes

      agpy.gaussfitter.onedgaussfit(xax, data, err=None, params=[0, 1, 0, 1], fixed=[False, False, False, False], limitedmin=[False, False, False, True], limitedmax=[False, False, False, False], minpars=[0, 0, 0, 0], maxpars=[0, 0, 0, 0], quiet=True, shh=True, veryverbose=False, vheight=True, negamp=False, usemoments=False) [source] ¶ Inputs:

      xax - x axis data - y axis err - error corresponding to data

      params - Fit parameters: Height of background, Amplitude, Shift, Width fixed - Is parameter fixed? limitedmin/minpars - set lower limits on each parameter (default: width>0) limitedmax/maxpars - set upper limits on each parameter quiet - should MPFIT output each iteration? shh - output final parameters? usemoments - replace default parameters with moments

      Returns a 1-dimensional gaussian of form H+A*numpy.exp(-(x-dx)**2/(2*w**2))

      Returns (height, amplitude, x, width_x) the gaussian parameters of a 1D distribution by calculating its moments. Depending on the input parameters, will only output a subset of the above.

      If using masked arrays, pass estimator=numpy.ma.median ‘estimator’ is used to measure the background level (height)

      negamp can be used to force the peak negative (True), positive (False), or it will be “autodetected” (negamp=None)

      Returns a 2d gaussian function of the form: x’ = numpy.cos(rota) * x - numpy.sin(rota) * y y’ = numpy.sin(rota) * x + numpy.cos(rota) * y (rota should be in degrees) g = b + a * numpy.exp ( - ( ((x-center_x)/width_x)**2 + ((y-center_y)/width_y)**2 ) / 2 )

      inpars = [b,a,center_x,center_y,width_x,width_y,rota] (b is background height, a is peak amplitude)

      where x and y are the input parameters of the returned function, and all other parameters are specified by this function

      However, the above values are passed by list. The list should be: inpars = (height,amplitude,center_x,center_y,width_x,width_y,rota)

      You can choose to ignore / neglect some of the above input parameters

      unumpy.sing the following options: circle=0 - default is an elliptical gaussian (different x, y


      Packaging has started and developers might try the packaging code in VCS

      Python3-astroalign: Astrometric registration of images when no WCS info is available

      ASTROALIGN is a python module that will try to align two stellar astronomical images, especially when there is no WCS information available.

      It does so by finding similar 3-point asterisms (triangles) in both images and deducing the affine transformation between them.

      Generic registration routines try to match feature points, using corner detection routines to make the point correspondence. These generally fail for stellar astronomical images, since stars have very little stable structure and so, in general, indistinguishable from each other. Asterism matching is more robust, and closer to the human way of matching stellar images.

      Python3-extinction: Fast interstellar dust extinction laws (Python 3)

      Extinction contains Cython-optimised implementations of empirical dust extinction laws found in the astronomical literature.

      This package contains the Python 3 version of the package.

      Python3-heliopy: Python for heliospheric and planetary physics

      A python library for heliospheric and planetary Physics. The primary goal of HelioPy is to provide a set of tools to download and read in data, and to carry out other common data processing tasks.

      Python3-pyspeckit: Python toolkit for fitting and manipulating spectroscopic data (Python 3)

      PySpecKit is a code framework designed to allow for analysis of spectroscopic data from a wide variety of astronomical instruments. Initial implementation focuses on optical and radio applications, e.g. gaussian and voigt profile fitting, baseline/continuum fitting, and equivalent width measurements.

      Python3-supersmoother: Python implementation of Friedman's Supersmoother (Python 3)

      This is an efficient implementation of Friedman’s SuperSmoother based in Python. It makes use of numpy for fast numerical computation

      This package installs the library for Python 3.


      Matplotlib.pyplot.plot¶

      The coordinates of the points or line nodes are given by x, y.

      The optional parameter fmt is a convenient way for defining basic formatting like color, marker and linestyle. It's a shortcut string notation described in the Notes section below.

      You can use Line2D properties as keyword arguments for more control on the appearance. Line properties and fmt can be mixed. The following two calls yield identical results:

      When conflicting with fmt, keyword arguments take precedence.

      Plotting labelled data

      There's a convenient way for plotting objects with labelled data (i.e. data that can be accessed by index obj['y'] ). Instead of giving the data in x and y, you can provide the object in the data parameter and just give the labels for x and y:

      All indexable objects are supported. This could e.g. be a dict , a pandas.DataFrame or a structured numpy array.

      Plotting multiple sets of data

      There are various ways to plot multiple sets of data.

      The most straight forward way is just to call plot multiple times. Example:

      As x and/or y are 2D arrays a separate data set will be drawn for every column. If both x and y are 2D, they must have the same shape. If only one of them is 2D with shape (N, m) the other must have length N and will be used for every data set m.

      The third way is to specify multiple sets of [x], y, [fmt] groups:

      In this case, any additional keyword argument applies to all datasets. Also this syntax cannot be combined with the data parameter.

      By default, each line is assigned a different style specified by a 'style cycle'. Die fmt and line property parameters are only necessary if you want explicit deviations from these defaults. Alternatively, you can also change the style cycle using rcParams["axes.prop_cycle"] (default: cycler('color', ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']) ).

      The horizontal / vertical coordinates of the data points. x values are optional and default to range(len(y)) .

      Commonly, these parameters are 1D arrays.

      They can also be scalars, or two-dimensional (in that case, the columns represent separate data sets).

      These arguments cannot be passed as keywords.

      fmt str, optional

      A format string, e.g. 'ro' for red circles. See the Notes section for a full description of the format strings.

      Format strings are just an abbreviation for quickly setting basic line properties. All of these and more can also be controlled by keyword arguments.

      This argument cannot be passed as keyword.

      data indexable object, optional

      An object with labelled data. If given, provide the label names to plot in x and y.

      Technically there's a slight ambiguity in calls where the second label is a valid fmt. plot('n', 'o', data=obj) could be plt(x, y) or plt(y, fmt) . In such cases, the former interpretation is chosen, but a warning is issued. You may suppress the warning by adding an empty format string plot('n', 'o', '', data=obj) .

      A list of lines representing the plotted data.

      These parameters determine if the view limits are adapted to the data limits. The values are passed on to autoscale_view .

      **kwargs Line2D properties, optional

      kwargs are used to specify properties like a line label (for auto legends), linewidth, antialiasing, marker face color. Example:

      If you specify multiple lines with one plot call, the kwargs apply to all those lines. In case the label object is iterable, each element is used as labels for each set of data.

      Here is a list of available Line2D properties:

      scatter XY scatter plot with markers of varying size and/or color ( sometimes also called bubble chart).

      Format Strings

      A format string consists of a part for color, marker and line:

      Each of them is optional. If not provided, the value from the style cycle is used. Exception: If line is given, but no marker , the data will be a line without markers.

      Other combinations such as [color][marker][line] are also supported, but note that their parsing may be ambiguous.


      Kyk die video: Ek kan nie omdraai nie #Joshua Jansen (Desember 2022).