• No results found

Study of the in-flight calibration of the SVOM/ECLAIRs instrument

N/A
N/A
Protected

Academic year: 2021

Share "Study of the in-flight calibration of the SVOM/ECLAIRs instrument"

Copied!
49
0
0

Loading.... (view fulltext now)

Full text

(1)

Study of the in-flight calibration of the

SVOM/ECLAIRs instrument

Jakob Östberg

Space Engineering, master's level 2020

Luleå University of Technology

(2)

Study of the in-flight calibration of the

SVOM/ECLAIRs instrument

Thesis submitted in partial fulfillment

of the requirements for the degree of

Master

in

Space Engineering

by

Jakob Östberg

based on research carried out

under the supervision of

Olivier Godet

and

Laurent Bouchet

January, 2020 performed at

(3)

Abstract

The Space based multi-band Variable astronomical Object Monitor (SVOM) is a x- and gamma-ray telescope with the primary objective of observing gamma-ray bursts. The mission is a cooperation between the French and Chinese space agencies and will be launched in 2021. Gamma-ray bursts are highly variable and energetic electromagnetic radiation that are generally created due to the collapse of a heavy star into a black hole or neutron star or a merger of two neutron stars. These extreme events appear as bright and short bursts of x- and gamma-rays followed by a longer-lived multi-wavelength afterglow emission. A gamma-ray burst can last from a few milliseconds up to a few thousands of seconds. Thanks to their brightness, they can be observed very far from Earth and therefore be used as cosmological probes to study the content of the early Universe. The satellite got a wide-field instrument, ECLAIRs that is in charge of detecting gamma-ray bursts and communicate their locations to the satellite and ground based telescopes which will repoint towards the gamma-ray burst to observe it. This will allow the gamma-ray bursts to be observed at multiple wavelengths simultaneously. ECLAIRs is a coded mask, photon counting instrument with the spectral range of 4 to 150 keV. The readout analog/digital electronics will measure the energy of each detected photon hitting the detection plane and encode it as a digital number (channel). To translate this digital number to a physical unit (keV) for scientific analysis purposes, the detectors are calibrated before launch by irradiating them with radiation from radioactive sources. During the lifetime of the spacecraft, the detectors will age due to the radiation environment and the channel to keV relationship will change over time. Therefore, it is necessary to periodically calibrate the detectors in flight. This is done by taking advantage of the fluorescence lines that always occur in the spectrum at the same energy regardless of the background spectrum. These lines are identified with spectral fitting techniques.

The aim of my internship is to study the best way to perform such a in-flight calibration. I investigate the need for implementing a data selection process to create the input data and the minimum amount of data required to recalibrate the channel to keV ratio. I also estimate the accuracy with which the reconstruction of the energy scale is done and I discuss if it is compliant with the instrument scientific requirements.

(4)

Contents

Abstract ii

List of Figures v

List of Tables vii

List of Abbreviations Acronyms viii

1 Introduction 1 1.1 Background . . . 1 1.1.1 Scientific context . . . 1 1.1.2 SVOM . . . 1 1.1.3 ECLAIRs . . . 2 1.1.4 Background spectrum . . . 5

1.2 Comparison of gamma-ray telescopes . . . 5

1.2.1 Swift - BAT . . . . 5

1.2.2 Integral - SPI . . . . 6

1.2.3 Integral - IBIS . . . . 7

1.2.4 Compton Gamma-ray Observatory - EGRET . . . . 7

1.2.5 Comparison . . . 8

1.3 Research purpose . . . 9

2 Theory 10 2.1 Factors influencing the background spectrum . . . 10

2.2 Error estimation . . . 11 2.2.1 Reduced χ2 . . . 11 2.2.2 Propagation of errors . . . 13 3 Method 14 3.1 Input data . . . 14 3.2 Data processing . . . 15 3.3 Spectral fitting . . . 15 3.3.1 Least squares . . . 17 iii

(5)

3.5 Error visualization . . . 18

3.5.1 Reduced χ2 . . . 18

3.5.2 Energy shift . . . 18

3.6 Investigated variations . . . 19

3.6.1 Excluded peak regions . . . 19

3.7 Centroid plot . . . 19

3.8 Import and division . . . 20

3.9 Configuration parameters . . . 21

4 Results 22 4.1 Processing of the code . . . 22

4.2 Linear fitting . . . 23

4.3 Visualization of calibration output . . . 24

5 Conclusion 25

References 27

Appendices 29

(6)

List of Figures

1.1 Overview of SVOM showing the various instruments and ground based

telescopes . . . 3

1.2 Visualisation of how a coded mask aperture can be used to deduce what direction a beam comes from. . . 4

1.3 Overview of the ECLAIRs instrument . . . 4

1.4 Overview of the BAT instrument. . . 5

1.5 Overview of the SPI instrument. . . 6

1.6 Overview of the EGRET instrument. . . 7

2.1 Photon absorption cross section for CdTe as a function of the energy of the photon. Yellow line shows the total photon absorption cross section. Rayleigh and Compton scattering as well as pair production does not have any noticeable impact on the total photon absorption cross section within the ECLAIRs energies (4 – 150 keV). Adapted from ’Notes on the data analysis in high-energy astrophysics’ by L. Foschini [1]. . . 11

2.2 Simulation of the expected ECLAIRs astrophysical and internal background induced by particles irradiating the instrument.A count is an energy deposit above the detection threshold of the electronics within one of the 6400 ECLAIRs pixels. Data are selected from a full orbit of the satellite. The vertical lines indicate the peaks that are used for the calibration of ECLAIRs. Exposure time is 427 days. . . 12

2.3 Simulation of the expected ECLAIRs astrophysical and internal background induced by particles irradiating the instrument. A count is an energy deposit above the detection threshold of the electronics within one of the 6400 ECLAIRs pixels. The vertical lines indicate the peaks that are used for the calibration of ECLAIRs. The exposure time used here is 33 days of data of when Earth blocking the field of view of ECLAIRs. . . 12

3.1 Peak regions visualized in red, green and blue in the ECLAIRs spectrum. Exposure time is 33 days and Earth blocking the field of view. . . 15

(7)

The reduced χ2is marking the goodness of the fit (dark blue line). Exposure time is 33 days. . . 16 3.3 Linear function fitted to data points. Residuals are shown in green. . . 17 3.4 Reduced χ2 as a function of exposure time for the third peak region. The

number for free variables for each data point are shown as n. . . 18 3.5 A visualization of the energy shift for four different exposure times. The

central dark blue line is the energy shift and the light blue region is the 1 sigma error region. The black dashed line represents the scientific requirements. . . 19 3.6 Energy shift as function of the energy when different peak regions are

excluded from the calculations. The central dark blue line is the energy shift and the light blue region is the 1 sigma error region. The black dashed line represents the scientific requirements. . . 20 3.7 Energy - channel relationship between input data and the estimated

correlation. Exposure time is 33 days. . . 20 3.8 Energy - channel relationship between input data and the estimated

correlation. Exposure time is 33 days. . . 21 4.1 A visualization of the energy shift during four different exposure times.

The central dark blue line is the energy shift and the light blue region is the 1 sigma error region. The black dashed line represents the scientific requirements. . . 22 4.2 Showing how a peak is fitted. The number of free parameters are noted by n.

The reduced χ2is marking the goodness of the fit (dark blue line). Exposure

time is 4 days. . . 23 4.3 Showing how a peak is fitted. The number of free parameters are noted by n.

The reduced χ2is marking the goodness of the fit (dark blue line). Exposure

(8)

List of Tables

1.1 Comparison of various gamma ray instruments . . . 5 4.1 Comparison of how long time it takes for three different functions to perform

a linear fit. . . 24

(9)

APC AstroParticule et Cosmologie CNES Centre National d’Études Spatiales CNSA China National Space Agency GRM Gamma-Ray burst Monitor

IRAP L’Institut de Recherche en Astrophysique et Planétologie IRFU Institut de Recherche sur les lois Fondamentales de l’Univers MXT Microchannel X-ray Telescope

PhD Doctor of Philosophy

SVOM Space-based multi-band astronomical Variable Objects Monitor VT Visible Telescope

(10)

Introduction

1.1

Background

1.1.1

Scientific context

Gamma-ray bursts are produced by energetic cosmological explosions and are the most energetic electromagnetic emission known to exist in the Universe. They are thought to originate from the collapse of some high-mass stars, when they form a black hole or neutron star [2]. The mass of these stars is larger than 20 solar masses. A merger of two neutron stars can also produce this phenomenon. These events produces ultra-relativistic jets that needs to be directed towards Earth for it to be possible to observe them. A black hole is a object with gravitational attraction so strong that nothing can escape it, no particles or electromagnetic radiation. A neutron star is an extremely dense remnant of a core of a star that went supernova and is largely composed of neutrons.

The bursts can last from only a few milliseconds to several minutes [3] and are followed by a multiwavelength afterglow that decays quickly but can last for days, weeks and even months [4][5]. In 2017, a merger of two neutron stars was observed by both gravitational wave detectors and electromagnetic wave detectors as a gamma-ray burst. This marked the start of multi-messenger astronomy [6].

1.1.2

SVOM

SVOM is the Space-based multi-band astronomical Variable Objects Monitor and is a mission developed jointly by the French Space Agency (CNES) and the China National Space Administration (CNSA) [7]. It will observe the transient sky in synergy with multi-messenger detectors, with a particular interest for gamma-ray bursts. It will study gamma-ray bursts and their afterglow. The spacecraft has four instruments that observe the sky in visible, x- and gamma-rays. The wide field instruments (ECLAIRs and the Gamma-Ray burst Monitor(GRM)) have two primary tasks. Firstly, ECLAIRs will detect and provide the position of the gamma-ray burst. Secondly, ECLAIRs and GRM will characterize the emission variation and the spectral properties of the prompt emission.

(11)

The narrow-field instruments (the Microchannel X-ray Telescope (MXT) and the Visible Telescope (VT)) will refine the localisation of the source of the gamma-ray burst and sample the emission flux over time.

When the SVOM platform receives source position from ECLAIRs, it checks if it’s possible to repoint the spacecraft towards the source. If it is, SVOM will perform a repointing maneuver to point the narrow field instruments towards the source. The source position is also transmitted to the ground so that ground based telescopes can point towards the source. This is done so that the source can be observed by a wide range of instruments. Due to the fact that gamma-ray bursts only last for a short amount of time, it is important that this is done quickly. A network of ground based visible telescopes will be installed along the SVOM orbit in Mexico and China.

SVOM is expected to detect around 70 gamma-ray burst per year and has a planned lifetime of three years with a possibility of a two year extension. The launch is planned for 2021 from Xichang, China with a Long March 2C launcher. The spacecraft will be in low Earth orbit with an altitude of around 650 km and an inclination of 30°. The spacecraft will use anti-solar pointing to make sure that it is always observing the Earths night sky to make it possible for ground based telescopes to do follow-up observations. The use of anti-solar pointing also means that Earth will block the field of view of the spacecraft instruments once per orbit.

1.1.3

ECLAIRs

One of ECLAIRs objectives is to detect gamma-ray bursts over a large fraction of the sky and to then to compute the position of the source and sending that position to the SVOM platform. The development of the instrument is under the supervision of CNES and is carried out by a collection of institutes: IRAP, IRFU and APC. ECLAIRs has a field of view of 2 steradians. A 2D coded mask is used to be able to tell the what direction the radiation comes from. Some of the light from the source will be obstructed by the coded mask so that a coded shade can be seen on the detector plane as illustrated by Figure 1.2. The origins of the beam can be mathematically reconstructed from this shadow.

The shielding is composed of copper (Cu) and lead (Pb) as seen in Figure 1.3. The main purpose of the shielding is to restrict the field of view of the instrument. The detector plane is composed of eight electronically independent sectors, each made of 800 Schottky cadmium telluride (CdTe) detectors, totalling 6400 detectors that will be operated at –20°C [8]. The total geometrical area of the detector is around 1000 cm². The mask to detector distance is 36 cm. The energy range is 4 – 150 keV and it will operate in photon counting mode which means that every photon interacting with the detector will be registered and stored in the on-board memory. Photons interacting with the CdTe detectors will create a charge cloud in the detector. This will be explained in section 2.1. A bias voltage of –300 V is used to

(12)

Figure 1.1: Overview of SVOM showing the various instruments and ground based telescopes

deplete the free charges and to collect the charge created. ECLAIRs is also composed of a radiator, an electronics box and a data processing unit. The data processing unit is managing the data flow and continuously scanning the data to detect gamma-ray bursts.

When a photon interacts with a detector, the energy will be encoded by the readout electronics as a number called channel over a 10 bits dynamic (i.e. 1024 channels). To find the real ECLAIRs data, the channel needs to be translated into a physical energy unit (keV). The channel to energy relationship of the detectors will be determined by pre-flight calibration using radioactive sources. However, this relationship will change differently over time for each detector due to the radiation environment effecting the detectors and electronics, hence the detectors needs to be calibrated regularly. The in-flight calibration will be done by observing the x- and gamma-ray background spectrum and the inherent fluorescence lines. This is discussed in chapter 2. It’s a scientific requirement for ECLAIRs to be able to determine the energy with an accuracy of±0.15 keV for the 4 – 60 keV energy range and±0.3 keV for the 60 - 150 keV range.

(13)

Figure 1.2: Visualisation of how a coded mask aperture can be used to deduce what direction a beam comes from.

(14)

1.1.4

Background spectrum

Cosmic diffuse x-ray background radiation originates from the accretion process of active galactic nuclei [9]. An active galactic nuclei is a region at the center of a galaxy that have a higher luminosity than normal due to its accretion process. The origin of the cosmic diffuse gamma-ray background radiation have been unconfirmed until recently when the Fermi gamma-ray telescope confirmed that the gamma-ray background originates from blazars, radio galaxies, and star-forming galaxies [9]. There are likely additional sources that are currently unknown.

1.2

Comparison of gamma-ray telescopes

Every space telescope needs to be calibrated to make sure that the produced data are interpreted correctly. This section discusses a few different techniques used by various space observatory missions to calibrate their detector. Both energy and gain calibration are discussed in this section. Gain calibration is the topic of this thesis and concerns finding the relation between channel and energy of a detected photon. Energy calibration concerns finding out the ratio between the detected photons and the real amount of photons that reached the detector plane. Each subsection will discuss one space observatory, introduce their detector and calibration method. Some detector parameters are compared in table 1.1.

Table 1.1: Comparison of various gamma ray instruments

Name Host satellite Effective range Spectral resolution FOV Type ECLAIRs SVOM 4 to 150 keV 1.5 keV at 60 keV 2 sr Coded mask

SPI Integral 20 keV to 8 MeV 2 keV at 1 MeV 0.2 sr Coded mask

BAT Swift 15 to 150 keV 3.3 keV at 60 keV 1.4 sr Coded mask

IBIS Integral 15 keV to 10 MeV 8 keV at 100 keV 0.58 sr Coded mask EGRET Compton 20 MeV to 24 GeV 10 keV 0.33 sr Spark chamber

1.2.1

Swift - BAT

Figure 1.4: Overview of the BAT instrument. The Neil Gehrels Swift Observatory is

a NASA space mission launched on November 20, 2014 to study gamma-ray bursts. It has considerable similarities with SVOM as it uses its Burst Alert Telescope (BAT) instrument to detect gamma-ray bursts over a large field of view and then repoints the spacecraft to do observations

(15)

with other instruments. The BAT has a coded-aperture mask, has an energy range of 15 – 150 keV, a field of view of 1.4 sr and a spectral resolution of 3.3 keV at 60 keV [10][11]. The detector material is CdZnTe and the detecting area is 5240 cm2.

The ground calibration of BAT was done by irradiating the detectors with radioactive sources with known line energies and intensities. This was done both with and without the mask. A test run where several sources of varying intensity was placed in the field of view of the instrument was also done. Each detector also has a calibration pulser circuit that injects a specified number of charge pulses on command. These pulses are recognised by the software and used to monitor the gain, offset and linearity of the channels of the instrument. In addition, a radioactive source,241Am, as well as observations of astronomical

sources was also used for in-flight calibration [12].

1.2.2

Integral - SPI

Figure 1.5: Overview of the SPI instrument. Integral is an ESA mission in

cooperation with the Russian Space Agency and NASA. The SPectrometer for Integral, SPI, uses a hexagonal coded mask and germanium detectors with a surface area of 500 cm2 [13]. The field of view of the instrument is 0.2 sr [14].

Extensive ground calibration was performed in two separate test campaigns where the instrument was irradiated with various radioactive sources. Detector efficiencies was determined as well as the homogeneity of the detection plane and imaging performance in the whole effective range of the instrument. The spectrometer is 238 cm high and has a mass of 1300kg.

The in-flight calibration consisted of observing sources such as Cygnus X-1

(16)

and the Crab nebula is a supernova remnant with the Crab pulsar in the center which emits strong X- and gamma-rays. Integral was launched on the 18th October 2002 and have now been operational for over 17 years.

1.2.3

Integral - IBIS

The Imager on Board the INTEGRAL Satellite (IBIS) was launched together with SPI on the Integral spacecraft in 2002. It uses a coded mask and have two independent detector planes which allows it to observe a wide range of energies. The first detector plane is made out of CdTe and can detect in the 15 – 1000 keV energy range and the second uses CsI detectors to observe the 0.175 – 10 MeV energy range.

The pre-flight calibration was done using several radioactive sources. The main in-flight observational calibration target was Cyg-X. IBIS also have a calibration unit on board consisting of a Ci20Na radioactive source.

1.2.4

Compton Gamma-ray Observatory - EGRET

The Energetic Gamma-Ray Experiment Telescope (EGRET) is a spark chamber detector within an energy range of 20 MeV – 24 GeV [15]. It was launched on-board the Compton Gamma-ray Observatory in 1991 and remained in orbit until 2000. As one can see in Figure 1.6, the central element of the detector is the multi-level spark chambers followed by the NaI energy measurement counter.

Figure 1.6: Overview of the EGRET instrument. The central part of the instrument

is covered by an anti-coincidence scintillation dome that will register when charged particles pass through to make sure that they are removed from the data. The gamma rays are detected indirectly by the electron-positron pair production that occur when the gamma-rays pass through the tantalum (73Ta) foils that are

situated within the spark chamber layers.

Pre-flight calibration was carried out by firing gamma-ray pulses at the instrument. The inside of the instrument walls was also irradiated to examine particles produced by interactions with the walls [16].

EGRET did not have an on-board calibration unit, so the main method of in-flight calibration was to observe steady astronomical gamma-ray sources. The best options for

(17)

this was pulsars and diffuse emissions from the galactic disc. Since the diffuse emissions from the galactic disk is in the field of view a lot more frequently than the pulsars, the diffuse emission form the galactic disk was used as a primary calibration source. The Crab, Vela and Geminga pulsars was used as secondary calibration targets. Calibration was done by comparing the observed intensity with a standard map. In-flight calibration was done after launch and after gas-refills of the spark chamber. To calibrate for the detection of radiation in the lower end of the spectrum, the EGRET team found that using lines in the spectrum caused by materials in the spacecraft itself was the only viable option. The two best lines was from radioactive40K in the spark chamber frames that gave a rise to a line at

1.46 MeV and and neutron capture by the iron in the spacecraft that gave rise in a line at 7.6 MeV.

1.2.5

Comparison

Four gamma-ray detectors were chosen to be studied of which three are built with similarities to ECLAIRs. The choice to study similar instruments was done to get a better insight in to how gamma-ray instruments are calibrated. The similar instruments: BAT, SPI and IBIS, all have a coded aperture mask, a detector plane made out of various compounds (CdZnTe, Ge and CdTe and CsI respectively) and a wide field of view.

All compared instruments were calibrated pre-flight by irradiating the detectors with gamma-rays of known energy. The test campaigns varied in length and procedure. The procedures varied from only irradiating from the front of the instruments at varying distances to a massive amount of incident angles covered, as well as irradiating the structure itself and not the detectors. This was done to investigate the signals received because of the different interactions that leads to photons being emitted from the structure of the spacecraft. All missions except EGRET used various radioactive sources to do this.

All but SPI had an on-board calibration unit. These calibration units all contained a radioactive source. All instruments observed astronomical sources for in-flight energy calibration purposes and the most common source was the Crab. Gain calibration was done using the fluorescence lines in the background spectrum.

The BAT instrument have an unique in-flight calibration method which is the built in pulser circuit that injects a charge on the detectors on command.

EGRET used observations of the diffuse radiation from the galactic disc to calibrate the instrument.

Other in-flight calibration methods that have been used by other instruments include calibration by observing laser fired from the ground and observing the Moon [17][18]. The laser from Earth calibration was done to calibrate an optical instrument and is not be

(18)

both gamma- and x-rays are absorbed by the Earths atmosphere, making it impossible for radiation of those energies, to be sent from the surface of the Earth to orbit without the use of a high-altitude balloon. The instrument using the moon as a calibration target observed infrared to ultraviolet radiation.

1.3

Research purpose

The purpose of this thesis is to study the in-flight calibration of the ECLAIRs instrument. This study is a continuation of work done by a previous intern at IRAP, Arvind Vairavan. A Python software have been created that calculates the channel to energy relationship. The energy scale needs to be reconstructed in keV so that the physical meaning of the data can be understood. The aim of this study is to develop tools that can evaluate the quality of the computations and to expand the functionality of the code by for example investigate the feasibility of various calibration techniques. The study was performed using Python 3.7. The numpy and scipy libraries have been key to this work.

(19)

Theory

2.1

Factors influencing the background spectrum

The absorption cross section seen in Figure 2.1 displays the prevalence of different photon interactions with the CdTe detectors. Photoelectric interactions dominate in the ECLAIRs energy range (4 – 150 keV) [19]. The energy deposited by a photon on a detector must exceed the threshold of the readout electronics to be registered.

The photoelectric effect

The photoelectric effect is when a photon is absorbed by an electron from an atom leading to the ionization of the atom.

Photons interacting with the CdTe detectors through the photoelectric effect will create a charge cloud in the detector. The energy of the charge cloud is proportional to the energy of the photon that interacted with the detector. A bias voltage of –300 V is used to move the charge cloud so that the readout electronics can read the energy of the charge cloud. The charge is then encoded as a channel over a 10 bits (1024 channels).

Fluorescence of spacecraft materials

The fluorescence process is a consequence of the ionization process of the materials around the detectors or within the detectors themselves.

The shielding of ECLAIRs contains Cu and Pb while the detector are made of CdTe. These materials are ionized by electromagnetic radiation or particles. When the ionized electron returns to its ground state it emits a photon of a given energy energy. Some of the emitted photons are registered by the detectors. Energies of the fluorescent photons are 8 keV for Cu, 23, 27.2 and 31.0 keV for CdTe and 72.8 and 75.0 keV for Pb. These energies stand out from the background when looking at the energy spectrum as seen in Figure 2.2 and are therefore used to calibrate the instrument. They are noted by vertical lines in Figure 2.3. The remaining peaks in the spectrum are also due to fluorescence interactions but are not used in this thesis.

(20)

Figure 2.1: Photon absorption cross section for CdTe as a function of the energy of the photon. Yellow line shows the total photon absorption cross section. Rayleigh and Compton scattering as well as pair production does not have any noticeable impact on the total photon absorption cross section within the ECLAIRs energies (4 – 150 keV). Adapted from ’Notes on the data analysis in high-energy astrophysics’ by L. Foschini [1].

Effect the Earth blocking the field of view

The majority of the low energy photons (4 – 50 keV) detected are from the x-ray background radiation which Earth blocks when passing in the field of view of the instrument. This leads to the low energy peaks looking more prominent in these data, see Figure 2.3. For that reason, the data used most frequently in this study are when Earth is blocking the field of view of ECLAIRs.

2.2

Error estimation

2.2.1

Reduced χ

2

To find the fluorescence peaks in the data, spectral fitting is used to model the shape of the peaks. This is discussed further in section 3.3. To estimate the goodness of fit of the spectral

(21)

Figure 2.2: Simulation of the expected ECLAIRs astrophysical and internal background induced by particles irradiating the instrument.A count is an energy deposit above the detection threshold of the electronics within one of the 6400 ECLAIRs pixels. Data are selected from a full orbit of the satellite. The vertical lines indicate the peaks that are used for the calibration of ECLAIRs. Exposure time is 427 days.

Figure 2.3: Simulation of the expected ECLAIRs astrophysical and internal background induced by particles irradiating the instrument. A count is an energy deposit above the detection threshold of the electronics within one of the 6400 ECLAIRs pixels. The vertical lines indicate the peaks that are used for the calibration of ECLAIRs. The exposure time used here is 33 days of data of when Earth blocking the field of view of ECLAIRs.

fitting, reduced χ2have been used in this study. Reduced χ2provides a measure of how well

(22)

ν

where χ2ν is the reduced χ2, ν are the number of degrees of freedom and χ² is

χ2 =∑ i (Oi− Ciσ2 i , (2.2)

where Oiis the ithobserved data point, Cithe ithmodelled estimation of the observed data

point and σi the ith 1 sigma error on the observed data point. The standard deviation is a

measure of the variation or spread among the observed data. A reduced χ2 close to 1 is

defined as a good fit.

2.2.2

Propagation of errors

Although there are several ways to calculate propagating errors, in this internship, the errors was computed by summing the error contributions in a quadratic way.

Given a function of two variables, z(x, y) with the variables x and y having measured errors δxand δy, the error of z is given by:

δz = √ (∂z ∂xδx)² + ( ∂z ∂yδy)² (2.3)

(23)

Method

3.1

Input data

The data used in this thesis come from a simulation of the photons ECLAIRs is expected to detect. The data are composed of a list of events, each containing the following information:

• Energy deposited following an interaction with a detector • Timestamp of when the interaction occurred

• Which of the 6400 pixels that was hit • Multiplicity

The latter describes if the event is a single event or not. A single event is when a single photon hits a detector within a set period of time. A multiple event is when two or more events are detected within a time window.

The multiplicity tagging on board is done for the purpose of the GRB trigger software implemented in the UGTS (DPU).

A particle shower induced by a particle hitting the body of the spacecraft and creating numerous secondary particles which can reach the detectors around the same time will give rise to multiple detected events. These events are not wanted in the data and are labeled as having a multiplicity of more than one. The multiplicity tagging on board is done so that the on-board processing unit ignore those events. Compton scattering and fluorescence can also give rise to detection of unwanted multiple events.

The data used in this thesis have been produced by a software created by IRAP PhD student Sujay Mate [21].

To create a spectrum, data with similar energies are grouped together in what is called ”bins”. One bin could be between the energies 110.0 and 110.3 keV for example. The amount of detected events within this energy range (in this bin) are then counted. This is done for all bins in the full energy range ( 4 – 150 keV) and then plotted, see Figure 2.2.

(24)

3.2

Data processing

The data produced by ECLAIRs will deliver the same parameters (energy, timestamp, pixel and multiplicity) as the simulated data except that the energy will be encoded by the readout electronics as a number called channel over a 10 bits dynamic (i.e. 1024 channels). To emulate the real ECLAIRs data, the energy needs to be translated into channels. This has been done with the equation:

Channel = Gain× Energy + Offset (3.1)

The gain and offset is chosen arbitrarily to be 7 keV−1and 0.5 respectively. Since ECLAIRs outputs the data in channels, the coefficients needs to be estimated so that the reconstruction of the energy scale in keV has an accuracy better than +/- 0.15 and 0.3 keV in the 4 – 60 keV and 60 – 150 range keV respectively. This is done by estimating the location of six peaks in the data and comparing those locations with the known energies of those peaks.

3.3

Spectral fitting

The six peaks mentioned in the previous section are divided into three peak regions. This was done in previous work by identifying the peaks visually. The 8 keV peak is in the first peak region, the 23, 27.2 and 31.0 keV peaks in the second peak region and the 72.8 and 75.0 keV peaks in the the third peak region. The peak regions are shown in Figure 3.1.

Figure 3.1: Peak regions visualized in red, green and blue in the ECLAIRs spectrum. Exposure time is 33 days and Earth blocking the field of view.

The regions were extracted from the data and a guess made on the underlying continuum on 15

(25)

the form of equation (3.3) that the spectrum would have had if the peak wasn’t there. Then a guess was made on the parameters describing the shape of the peaks. The peaks are assumed to have a Gaussian shape that is given by the equation:

G(O) = 1

σ√2πe

−(O−C)²

2σ² , (3.2)

where σ is the standard deviation, C the central location of the peak and O the observed value, i.e. the data. Figure 3.2 shows the peak fitted to the 74 keV peak region data (shown in blue in Figure 3.1). After a guess have been made on the linearity of the underlying data, a guess on the Gaussian parameters is made. There are two Gaussian parameters per peak: C and σ. The linear and Gaussian guesses can be seen in red and magenta colored lines respectively in Figure 3.2. The guessed values and the data are then used as input for the scipy.optimize.curve_fit() method that then estimates the fit using either the Levenberg–Marquardt or a trust region algorithm. The estimated linear and Gaussian fits can be seen in light and dark blue respectively in Figure 3.2. The guess values for the linear and Gaussian functions are set manually and have the same values every time the software runs regardless of input data. The guess is tailor made to fit data of when earth is blocking the field of view. A new method needs to be created to figure out how the software automatically can make a guess on based on the input data.

Figure 3.2: Showing how a peak is fitted. The number of free parameters is noted by n. The reduced χ2 is marking the goodness of the fit (dark blue line). Exposure time is 33 days.

This is done with all three peak regions to find the central location, C of the six peaks. The central locations of the peaks are used to find the channel to energy relationship. Since the energies of the peaks are known (from fluorescence interactions), linear fitting can be used

(26)

peaks. This relationship is given by equation (3.1).

3.3.1

Least squares

To be able to accurately fit a line to data, the least square method is often used. That is the case for the Levenberg–Marquardt algorithm that is used in this study. This method minimizes the sum of the squares of the residuals, were a residual is the difference between the observed value and that of the predicted value. They are visualized in green in Figure 3.3.

Figure 3.3: Linear function fitted to data points. Residuals are shown in green.

3.4

Linear fitting

Three linear fitting functions was compared to investigate the accuracy of the results and the time it took to find them. Two functions from Python packages was used: scipy.optimize.curve_fit() and numpy.polyfit(). The third one named LinRegStand() was created from scratch using the following equations:

if y = kx + m, (3.3) then k =(x− ¯x)(y − ¯y)(y− ¯y)2 (3.4) 17

(27)

and

m = ¯y− k¯x (3.5)

Where ¯x and ¯y are the mean of x and y respectively.

3.5

Error visualization

3.5.1

Reduced χ

2

Code was written to visualize the reduced χ2of the results as a function of the exposure time. The result can be seen in Figure 3.4. One can see that the goodness of the fit increases with decreasing exposure time.

Figure 3.4: Reduced χ2as a function of exposure time for the third peak region. The number for free variables for each data point are shown as n.

3.5.2

Energy shift

Code was written to visualize the energy shift. The energy shift is defined as:

Energy shif t = Real energy− Estimated energy, (3.6) where

Estimated energy = Channel− Offset

Gain , (3.7)

(28)

That is, energy shift is a measure of the quality of the calibration. The scientific requirements of ECLAIRs demands that the energy shift is less than 0.15 keV for events in the 4 – 60 keV energy range and less than 0.3 keV for events in the 60 – 150 keV energy range. A visualization of the energy shift and the scientific requirements can be seen in Figure 3.5. The shaded region is the 1 sigma error region calculated with the error propagation technique discussed in section 2.2.2.

Figure 3.5: A visualization of the energy shift for four different exposure times. The central dark blue line is the energy shift and the light blue region is the 1 sigma error region. The black dashed line represents the scientific requirements.

3.6

Investigated variations

3.6.1

Excluded peak regions

An investigation was done to get some insight into how not using some peaks regions for the calibration would effect the outcome. One of the three peak regions was excluded, one at a time to investigate the impact on the energy shift. The result can be seen in Figure 3.6.

3.7

Centroid plot

To compare the result with the input, a centroid plot was created. Figure 3.7 shows the full plot and Figure 3.8 the same plot but zoomed in on the data point around channel 218 ( 31.0 keV peak). The plots show the real correlation between energy and channel as well as the estimated one.

(29)

from the calculations. The central dark blue line is the energy shift and the light blue region is the 1 sigma error region. The black dashed line represents the scientific requirements.

Figure 3.7: Energy - channel relationship between input data and the estimated correlation. Exposure time is 33 days.

3.8

Import and division

When the data are imported to the python program, the data are given in energy and not channels. Therefore, the data should first be translated from energy to channels to imitate data that would be received during the mission. This was not the case in the software that was developed in a previous internship. Hence a new import method was developed. The

(30)

Figure 3.8: Energy - channel relationship between input data and the estimated correlation. Exposure time is 33 days.

3.9

Configuration parameters

To make the software easier to use for different purposes, global configuration parameters was added to easily control for example the exposure time and what plots to output. The exposure times to chose from by default are 533, 266, 133, 66 days and so on, always dividing by two for each next exposure time. The number of runs to do in a row can also be chosen. Other configuration parameters controls what plots to be output.

(31)

Results

4.1

Processing of the code

It was found that the software in its pre-existing state could calibrate a detector roughly within the scientific requirements when using data with exposure times 50 hours or greater as seen in Figure 4.1. The software breaks down at shorter exposure times since it’s unable to properly fit the 8 keV peak with less amount of datapoints. Compare Figure 4.2 where the peak is fitted properly and Figure 4.3 where it is not. This can partly be attributed to that the shape of the peak can’t be seen in the sparsely populated 25 h dataset. Since the Earth will be blocking the field of view of ECLAIRs roughly a third of the time, it will take around 150 hours to collect 50 hours of the data needed for this calibration. That corresponds to 6.25 days or roughly one week.

Figure 4.1: A visualization of the energy shift during four different exposure times. The central dark blue line is the energy shift and the light blue region is the 1 sigma error region. The black dashed line represents the scientific requirements.

(32)

Figure 4.2: Showing how a peak is fitted. The number of free parameters are noted by n. The reduced χ2is marking the goodness of the fit (dark blue line). Exposure time is 4 days.

Figure 4.3: Showing how a peak is fitted. The number of free parameters are noted by n. The reduced χ2 is marking the goodness of the fit (dark blue line). Exposure time is 25 hours.

4.2

Linear fitting

Three linear fitting functions: scipy.optimize.curve_fit(), LinRegStand() and numpy.polyfit() are compared in Table 4.1. All three functions yields the same resulting value of the gain and offset in equation 3.1. Note that the execution time of the curve_fit() function varies depending on the quality of a guess that needs to be made before the function can run. The guess for this test was reasonable but not exact. LinRegStand() is the

(33)

code that would take overflow or bad input into account. The curve_fit() function can be unpredictable since it relies on a guess to be made before running. The polyfit() function is both robust and flexible but it takes a longer time to run. If it was used to calibrate all 6400 pixels, it would take around six and a half minutes to run this method alone or 34 orbits.

Number of datapoints Time (curve_fit) Time (LinRegStand) Time (polyfit) 6 0.87 ms 0.13 ms 61.40 ms 10 1.14 ms 0.13 ms 28.11 ms 100 1.04 ms 0.16 ms 0.45 ms

Table 4.1: Comparison of how long time it takes for three different functions to perform a linear fit.

4.3

Visualization of calibration output

Several methods have been developed to visualize the fitting and calibration results.

The reduced χ² plots are evaluating the goodness of the fit that the scipy.optimize.curve_fit() function is producing. They show that the fit is good on low exposure times. The energy shift plots visualize the overall calibration accuracy and show decreased accuracy and increased error with decreasing exposure time. They show that the calibration is mostly within the scientific requirements down to an exposure time of 50 hours. They have also been used to show that the software have difficulty handling data from a full orbit.

(34)

Conclusion

SVOM is a French/Chinese space mission dedicated to the study of gamma-ray bursts and high-energy transients in synergy with ground-based multi-messenger detectors. To detect gamma-ray bursts and other transients, the prime instrument on-board SVOM is the coded mask camera ECLAIRs that will scan a large fraction of the sky in an autonomous manner.

ECLAIRs with its CdTe detectors will do photon counting and encode the energy of each photon on 10 bits (1024 channels). The channels needs to be translated to physical units of energy for scientific analysis to be possible, the detector is therefore calibrated on ground to find the channel to energy relationship. During the lifetime of the mission, the channel to energy relationship of each detector will drift due to the radiation environment, therefore periodic calibration is needed during the mission. To monitor any change in the channel to keV relationship, we will use the instrument fluorescence lines from the ECLAIRs background. During my internship, I investigated the best strategy to put in place in order to perform such a monitoring. Error estimations of different strategies have been created as well as figures visualizing the accuracy of the calibration. Areas of improvement have also been identified.

The methods developed to estimate and visualize the errors resulting from the spectral fitting and calibration results will make it easier to evaluate the improvements that needs to be done to the software in the future. It can be concluded from Figure 3.6 that excluding a peak region from the calibration will not produce acceptable results. An investigation should be made to evaluate the impact of using additional fluorescence peaks in addition to the six peaks used in this study.

It has been found that the software can calibrate a detector within the scientific requirements when using data of when Earth is blocking the field of view if the exposure time is around 50 hours and longer. These data could take up to seven days for the spacecraft to collect. This is acceptable since experience from previous missions tells us that it could take up to a month before the detectors have drifted enough to be in need of a recalibration. However, the detectors will drift more rapidly in the period following the launch.

(35)

collect the data, the more the detectors drift between each calibration. Continued work could focus on making the software able to calibrate data from shorter timescales while keeping the errors within the scientific requirement. The already found software is customized to work with data of when Earth is blocking the field of view. It is needs to be generalized to work well with any data. One example is that the three peak regions have in previous work been selected by arbitrarily visual means and are therefore customized to the data of when Earth is blocking the field of view of ECLAIRs.

The time it takes for the calibration software to run also needs to be taken into account and minimized as much as possible while still staying within the scientific requirements. Therefore, making the software run faster could also be an area of continued work. Creating a better guess for the Gaussian parameters for the peaks could be one way to decrease the execution time of the software.

This thesis work has found that calibrating using fluorescence lines is a feasible technique that will work within the scientific requirements. With some suggested improvements to the software, it will likely decrease the error region of the energy shift, decrease the amount of data needed and decrease the calibration time.

(36)

References

[1] Foschini, L., 2009. Notes on the data analysis in high-energy astrophysics. [2] Gehrels, N., and Meszaros, P., 2012. “Gamma ray bursts”. Science, 337(932).

[3] Fishman, G. J., and Hartmann, D. H., 1998. “Gamma-ray bursts: New observations illuminate the most powerful explosions in the universe”. Scientific American.

[4] Jensen, B. L., Fynbo, J. U., Gorosabel, J., Hjorth, J., Holland, S., Møller, P., Thomsen, B., Björnsson, G., Pedersen, H., Burud, I., Henden, A., Tanvir, N. R., Davis, C. J., Vreeswijk, P., Rol, E., Hurley, K., Cline, T., Trombka, J., McClanahan, T., Starr, R., Goldsten, J., Castro-Tirado, A. J., Greiner, J., Bailer-Jones, C. A. L., Kümmel, M., and Mundt, R., 2001. “The afterglow of the short/intermediate-duration gamma-ray burst grb 000301c: A jet at z = 2.04”. Astronomy Astrophysics, 370.

[5] Michelson, P. F., Atwood, W. B., and Ritz, S., 2010. “Fermi gamma-ray space telescope: High-energy results from the first year”. Reports on Progress in Physics, 73(7).

[6] Abbott, B. P., Abbott, R., Abbott, T. D., Acernese, F., Ackley, K., Adams, C., Adams, T., Addesso, P., Adhikari, R. X., and Adya, V. B., 2017. “Gravitational waves and gamma-rays from a binary neutron star merger: Gw170817 and grb 170817a”. The Astrophysical Journal Letters„ 848(2).

[7] Wei, J., Cordier, B., Antier, S., Antilogus, P., Atteia, J. L., Bajat, A., Basa, S., Beckmann, V., Bernardini, M. G., Boissier, S., Bouchet, L., Burwitz, V., Claret, A., Dai, Z. G., Daigne, F., Deng, J., Dornic, D., Feng, H., Foglizzo, T., Gao, H., Gehrels, N., Godet, O., Goldwurm, A., Gonzalez, F., Gosset, L., Götz, D., Gouiffes, C., Grise, F., Gros, A., Guilet, J., Han, X., Huang, M., Huang, Y. F., Jouret, M., Klotz, A., Marle, O. L., Lachaud, C., Floch, E. L., Lee, W., Leroy, N., Li, L. X., Li, S. C., Li, Z., Liang, E. W., Lyu, H., Mercier, K., Migliori, G., Mochkovitch, R., O’Brien, P., Osborne, J., Paul, J., Perinati, E., Petitjean, P., Piron, F., Qiu, Y., Rau, A., Rodriguez, J., Schanne, S., Tanvir, N., Vangioni, E., Vergani, S., Wang, F. Y., Wang, J., Wang, X. G., Wang, X. Y., Watson, A., Webb, N., Wei, J. J., Willingale, R., Wu, C., Wu, X. F., Xin, L. P., Xu, D., Yu, S., Yu, W. F., Yu, Y. W., Zhang, B., Zhang, S. N., Zhang, Y., and Zhou, X. L., 2016. The deep and transient universe in the svom era: New challenges and opportunities - scientific prospects of the svom mission.

[8] Takahashi, T., and Watanabe, S., 2001. “Recent progress in cdte and cdznte detectors”. IEEE Transactions

on Nuclear Science, 48(4).

[9] Inoue, Y., 2014. “Cosmic gamma-ray background radiation”. 5th Fermi Symposium.

[10] NASA, 2012. “Swift’s burst alert telescope (bat)”. https://swift.gsfc.nasa.gov/about_swift/bat_desc.html. [11] Parsons, A., Tuller, J., Krimm, H., Barthelmy, S., Cummings, J., Markwardt, C., Hullinger, D., Gehrels, N., Fenimore, E., Palmer, D., Sato, G., Nakazawa, K., Takahashi, T., Watanabe, S., Okada, Y., Takahashi,

(37)

H., Suzuki, M., and Tashiro, M., 2004. “Swift/bat calibration and the estimated bat hard x-ray survey sensitivity”. Proceedings of SPIE, 5165.

[12] Barthelmy, S. D., 2000. “The burst alert telescope (bat) on the swift midex mission”. Proceedings of

SPIE, 4140.

[13] Schanne, S., Cordier, B., Gros, M., Attié, D., v. Ballmoos, P., Bouchet, L., Carli, R., Connell, P., Diehl, R., Jean, P., Kiener, J., v. Kienlin, A., Knödlseder, J., Laurent, P., Lichti, G., Mandrou, P., Paul, J., Paul, P., Roques, J.-P., Sanchez, F., Schönfelder, V., Shrader, C., Skinner, G., Strong, A., Sturner, S., Tatischeff, V., Teegarden, B., Vedrenne, G., Weidenspointner, G., and Wunderer, C., 2003. “Calibration of the spectrometer aboard the integral satellite”. Proceedings of SPIE, 4851.

[14] Kienlin, A. v., Arend, N., Lichti, G., and Strong, A., 2004. “Gamma-ray burst detection with integral/spi”.

arXiv.

[15] Esposito, J. A., Bertsch, D. L., Chen, A. W., Dingus, B. L., Fichtel, C. E., Hartman, R. C. Hunter, S. D., Kanbach, G., Kniffen, D. A., Lin, Y. C., Mayer-Hasselwander, H. A., McDonald, L. M., Michelson, P. F., Montigny, C. v., Mukherjee, R., Nolan, P. L., Schneid, E., Sreekumar, P., Thompson, D. J., Tompkins, W. F., and Willis, T. D., 1998. “In-flight calibration of the energetic gamma-ray experiment telescope (egret) on the compton gamma-ray observatory”. NASA preprint.

[16] Thompson, D. J., Bertsch, D., Favale, A., Fichtel, C., Hartman, R., Hofstadter, R., Hughes, E., Hunter, S., Hughlock, B., Kanbach, G., Kniffen, D., Lin, Y., Mattox, J., Mayer-Hasselwander, H., Nolan, P., Pinkau, K., Rothermel, H., Schneid, E., Sommer, M., and Walker, A. H., 1987. “Calibration of the egret high-energy gamma-ray telescope in the range 20-10,000 mev with a tunable beam of quasi-monoenergetic gamma-rays at slac”. IEEE Transactions on Nuclear Science, NS-34(1).

[17] Volvach, A., Dmitrotsa, A., Neyachenko, D., Grebenyuk, V., Gorbunov, N., Lavrova, M., Tkachev, L., E., P., Caramete, A., Chiritoi, G., and Radu, A. A., 2017. “The tus space experiment: calibration in flight”. In Procedings of Science, Vol. 177, 35th International Cosmic Ray Conference.

[18] Daniels, J. L., Smith, G. L., Priestley, K. J., and Thomas, S., 2014. “Using lunar observations to validate in-flight calibrations of clouds and earth radiant energy system instruments”. Transactions on Geoscience

and Remote Sensing, 53(09).

[19] Hirayama, H., 2000. “Lecture note on photon interactions and cross sections”. In KEK Internal, Monte Carlo 2000 Conference: Advanced Monte Carlo for Radiation Physics, Particle Transport Simulation and Applications.

[20] Bauer, W., 1999. “Error propagation”. http://lectureonline.cl.msu.edu/ mmp/labs/error/e2.htm.

[21] Mate, S., Bouchet, L., Atteia, J.-L., Claret, A., Cordier, B., Dagoneau, N., Godet, O., Gros, A., Schanne, S., and Triou, H., 2019. “Simulations of the svom/eclairs dynamic background: a fast, accurate and general approach for wide-field hard x-ray instruments”. Experimental Astronomy, 11.

(38)

Appendices

(39)

Some Python functions

1 def plot_redchisq(chisq, time, peak, data_len):

2 """

3 #Author: Jakob Ostberg

4 #Date: 13-11-2019

5 #plot reduced ChiSquare as a function of dataset length

6 input:

7 chisq: array with reuced chi square values

8 time: arary with exposure times corresnding to each reduced chi

square value

,→

9 peak: integer inicating which peak region is input

10 data_len: contains information about how many datapoints is in

each peak region

,→ 11 """ 12 13 if peak == 1: 14 peakE = "8 keV" 15 elif peak == 2: 16 peakE = "27 keV" 17 elif peak == 3: 18 peakE = "74 keV" 19 else: 20 peakE = "UNDEFINED" 21

22 n = [None] * len(chisq) 23

24 #number of parameters used to fit each peak sequenece 25 nparams = [5, 11, 8]

(40)

27 #calculate the degrees of freedom n for each reduced chi2 value: n = number of data points - number of parameters

,→

28 for x in range(len(chisq)):

29 n[x] = data_len[peak-1] / (2**x) - nparams[peak-1] 30

31 #plot values 32 plt.figure()

33 plt.semilogx(time, chisq,'*')

34 plt.ylabel('Reduced chi square', fontsize = 35) 35 plt.xlabel('Exposure time(days)', fontsize = 35)

36 plt.text(time[:-1][int(len(chisq)/2)],np.max(chisq),"%s peak " % peakE )

,→

37 #display n on plot

38 ybottom, ytop = plt.ylim() 39 yrange = ytop - ybottom 40 for x in range(len(chisq)):

41 plt.text(time[x],chisq[x]+(-0.1+0.15*(x%2))*yrange,"n = %s" %

int(np.floor(n[x])) )

,→

1 def getData(): 2 """

3 Author: Jakob Ostberg

4 Date: 27-11-2019

5 Prepare input data to imitate real data from ECLAIRs

6 output:

7 channels_Mul1: all events with multiplicity 1 in channels

8 channels_Mul2: all events with multiplicity 2 in channels

9 bins: histogram bins relating to channels_Mul1 and channels_Mul1

10 """ 11

12 #load the already ready data to save time

13 channels_mul1, channels_mul2, last_input = pickle.load(open(

"save.p", "rb" ))

,→ 14

15 # Only do all the timeconsuming stuff if the input file changed 16 if (last_input != inputFile) or (updateInput != 0):

17 print("Reloading data from source file") 18 print("input file = %s" % inputFile)

19 #open file in fits format to extract data 20 dataset,hdr = opensp(inputFile)

(41)

21 #retrieve data from all pixels and save as if it was all from the same pixel. With multiplicity 1 and 2 seperatly

,→

22 dataset_mul1 = dataset[(dataset.field(4)==1) & (dataset.field(1)>=Emin) &

(dataset.field(1)<=Emax)].field(1)

,→ ,→

23 dataset_mul2 = dataset[(dataset.field(4)==2) & (dataset.field(1)>=Emin) & (dataset.field(1)<=Emax)].field(1) ,→ ,→ 24 # Convert to channels 25 channels_mul1 = EnergytoChannel(dataset_mul1) 26 channels_mul2 = EnergytoChannel(dataset_mul2) 27 # Round off every value

28 channels_mul1 = [ round(i) for i in channels_mul1 ] 29 channels_mul2 = [ round(i) for i in channels_mul2 ] 30

31 pickle.dump( [channels_mul1, channels_mul2 , inputFile], open(

"save.p", "wb" ) )

,→

32 else:

33 print("Loading already prepared data") 34

35 #shorten data to match wanted exposure time 36 channels_mul1 =

channels_mul1[:len(channels_mul1)//(2**startDivision)]

,→

37 channels_mul2 =

channels_mul2[:len(channels_mul2)//(2**startDivision)]

,→ 38

39 #Divide into the given amount of channels (the number of channels ECLAIRs will give)

,→

40 countsMul1, bins = np.histogram(channels_mul1, bins = ChMax-1, density = False)

,→

41 countsMul2, bins = np.histogram(channels_mul2, bins = ChMax-1, density = False)

,→ 42

43 #Round off bins

44 bins = [ int(round(i)) for i in bins ] 45 bins = np.asarray(bins)

46

(42)

2 """

3 Author: Jakob Ostberg

4 Date: 27-11-2019

5 Prepare input data to imitate real data from ECLAIRs

6 input:

7 channels_Mul1: all events with multiplicity 1 in channels

8 channels_Mul2: all events with multiplicity 2 in channels

9 bins: histogram bins relating to channels_Mul1 and channels_Mul1

10 output:

11 dataset_ch_peak1, dataset_ch_peak2 and dataset_ch_peak3: arrays

of the peaks in channels

,→

12 bin1, bin2 and bin3: histogram bins relating to dataset_ch_peak1,

dataset_ch_peak2 and dataset_ch_peak3

,→ 13 """ 14 dataset_ch_peak1 = [] 15 dataset_ch_peak2 = [] 16 dataset_ch_peak3 = [] 17 bin1 = [] 18 bin2 = [] 19 bin3 = [] 20

21 R1minCh = translate(R1minE, Emin, Emax, ChMin, ChMax) 22 R1maxCh = translate(R1maxE, Emin, Emax, ChMin, ChMax) 23 R2minCh = translate(R2minE, Emin, Emax, ChMin, ChMax) 24 R2maxCh = translate(R2maxE, Emin, Emax, ChMin, ChMax) 25 R3minCh = translate(R3minE, Emin, Emax, ChMin, ChMax) 26 R3maxCh = translate(R3maxE, Emin, Emax, ChMin, ChMax) 27

28 dataset_ch_peak1 = channels_mul1[int(R1minCh):int(R1maxCh)] 29 bin1 = bins[int(R1minCh):int(R1maxCh)]

30 dataset_ch_peak2 = channels_mul2[int(R2minCh):int(R2maxCh)] 31 bin2 = bins[int(R2minCh):int(R2maxCh)]

32 dataset_ch_peak3 = channels_mul1[int(R3minCh):int(R3maxCh)] 33 bin3 = bins[int(R3minCh):int(R3maxCh)]

34

35 mode = 1

36 if mode == 1:

37 ch = channels_mul1 + channels_mul2

38 dataset_ch_peak1 = ch[int(R1minCh):int(R1maxCh)] 33

(43)

39 bin1 = bins[int(R1minCh):int(R1maxCh)]

40 dataset_ch_peak2 = ch[int(R2minCh):int(R2maxCh)] 41 bin2 = bins[int(R2minCh):int(R2maxCh)]

42 dataset_ch_peak3 = ch[int(R3minCh):int(R3maxCh)] 43 bin3 = bins[int(R3minCh):int(R3maxCh)]

44 45 plt.yscale("log") 46 plt.plot(bins[:-1],ch,'y') 47 plt.plot(bin1,dataset_ch_peak1,'r') 48 plt.plot(bin2,dataset_ch_peak2,'g') 49 plt.plot(bin3,dataset_ch_peak3,'b') 50 plt.xlabel('Channels', fontsize = 35) 51 plt.ylabel('Counts', fontsize = 35) 52

53 return dataset_ch_peak1, dataset_ch_peak2, dataset_ch_peak3, bin1, bin2, bin3

,→

1 def translateList(lista, oldMin, oldMax, newMin, newMax): 2 """

3 Author: Jakob Ostberg

4 Date 10-12-2019

5 maps a list from one range to another

6 """

7 newList = [0] * len(lista) 8

9 for i in range(len(lista)):

10 newList[i] = translate(lista[i],oldMin, oldMax, newMin, newMax)

,→ 11

12 return newList

1 def plotCentroidsM(energy, channels, channel_centroids_est,

centroid_errors, param, peak_Epos):

,→ 2 """

3 Author: Jakob Ostberg

4 Date: 05-12-2019

5 Plot keV vs Channels and display the centroids and their error

6 Input:

(44)

9 channel_centroids_est: estimated locations of the centers of the

peaks in channels

,→

10 centroid_errors: estimated errors of the channel_centroids_est

11 param: gain and offset

12 peak_Epos: locations of the centers of the peaks in keV

13 """

14 energy = energy[:600] 15 channels = channels[:600] 16 plt.figure()

17 #estimated energy given the found gain and offset

18 energy_centroid_est = (channel_centroids_est - param[1]) / param[0]

,→ 19

20 centroids_ch_real = EnergytoChannel(peak_Epos) 21

22 energy_estimated = (channels - param[1]) / param[0] 23

24 #plotting

25 plt.plot(channels, energy, 'b', label='real coorelation') 26 plt.plot(channels, energy_estimated, 'r', label='estimated

coorelation')

,→

27 plt.plot(centroids_ch_real, peak_Epos, '.b', label='real centroid

location') #real

,→

28 plt.plot(channel_centroids_est, energy_centroid_est, '.r', label='estimated centroid location') #estimated

,→

29 plt.errorbar(channel_centroids_est,

energy_centroid_est,xerr=centroid_errors, fmt= 'go', markersize = 2,capsize=2, label ='Centroid error')

,→ ,→

30 plt.xlabel('Channels', fontsize = 35) 31 plt.ylabel('Energy [keV]', fontsize = 35) 32 plt.legend(loc='best')

1 def linRegStand(x, y): 2 """

3 Author: Jakob Ostberg

4 Date: 06-12-2019

5 Perform linnear regression

6 Input:

7 x: x vector

8 y: y vector

(45)

9 Return:

10 gain: gain or slope of the linear function

11 offset: offset or y intercept of the linear function

12 """

13 xmean = np.mean(x) 14 ymean = np.mean(y) 15

16 gain = np.sum((x-xmean)*(y-ymean)) / np.sum((x-xmean)**2) 17 offset = ymean - gain*xmean

18

19 return gain, offset

1 def visualize_shift(dataset_full, pcoef, err, collection_time):

2 """

3 Author: Jakob Ostberg

4 Date: 15-11-2019

5 Visualize how the energy has been distorted by this software

6 Input:

7 dataset_full: all data

8 pcoef: gain and offset

9 err: gain and offset error

10 collection_time: exposure time

11 """ 12 13 Eest = [0] * 3 14 deltaE = [0] * 3 15 x1, x2 = [4, 150] 16 lim1, lim2 = [0.15, 0.3]

17 # Gain = [Gain, Gain+error; Gain-error]

18 G = [ pcoef[0], pcoef[0]+err[0], pcoef[0]-err[0] ] 19 # offset = [offset, offset+error; offset-error] 20 ofs = [ pcoef[1], pcoef[1]+err[1], pcoef[1]-err[1] ] 21 22 #create subplots 23 global shiftCounter 24 shiftCounter = shiftCounter + 1 25 if shiftCounter == 1: 26 plt.figure() 27 if noOfRuns != 1:

(46)

29 if compPeakUse != 0:

30 plt.subplot(2, 2, shiftCounter) 31 #plt.figure()

32

33 Ecounts_full, Ebins_full = np.histogram(dataset_full, bins = 1024, density = False)

,→

34 channels_full = EnergytoChannel(dataset_full)

35 Ccounts_full, Cbins_full = np.histogram(channels_full, bins = 1024, density = False)

,→

36 Ebins_full = (Ebins_full[1:] + Ebins_full[:-1])/2 37 Cbins_full = (Cbins_full[1:] + Cbins_full[:-1])/2 38 for x in range(3):

39 Eest[x] = (Cbins_full - ofs[x]) / G[x] 40 deltaE[x] = Ebins_full - Eest[x]

41 if collection_time/86400 < 3: 42 timescale = "hours" 43 time = math.floor(collection_time/3600) 44 else: 45 timescale = "days" 46 time = math.floor(collection_time/86400) 47 48 if compPeakUse != 0: 49 if shiftCounter == 1:

50 timescale = timescale + " (All peaks)" 51 elif shiftCounter == 2:

52 timescale = timescale + " (8 & 27 keV peaks)" 53 elif shiftCounter == 3:

54 timescale = timescale + " (27 & 74 keV peaks)" 55 elif shiftCounter == 4:

56 timescale = timescale + " (8 & 74 keV peaks)" 57 58 Gerr = err[0] 59 Oerr = err[1] 60 Gest = pcoef[0] 61 62 dDEdG = (-Eest[0]*Gerr/Gest)**2 63 dDEdO = ( - 1 / Gest )**2 * Oerr**2 64 DEerr = sqrt(dDEdG + dDEdO)

65

(47)

66 plt.plot(Ebins_full, deltaE[0], label="Collection time = %s %s" % (time , timescale))

,→

67 plt.fill_between(Ebins_full, (deltaE[0] + DEerr), (deltaE[0] -DEerr), alpha=0.5)

,→ 68

69 # add lines representing scientific requirements

70 plt.hlines(lim1, x1, 80, colors='k', linestyles='dashed') 71 plt.hlines(-lim1, x1, 80, colors='k', linestyles='dashed') 72 plt.hlines(lim2, 80, x2, colors='k', linestyles='dashed') 73 plt.hlines(-lim2, 80, x2, colors='k', linestyles='dashed') 74 plt.vlines(80, -lim2, -lim1, colors='k', linestyles='dashed') 75 plt.vlines(80, lim2, lim1, colors='k', linestyles='dashed') 76

77 plt.legend(loc='upper left')

78 plt.xlabel('Energy (keV)', fontsize = 30)

79 plt.ylabel('Energy shift (keV)', fontsize = 30)

1 def compPeakUseMet(Ecal, pos, errpos, dataset_full, duration_dataset,

pcoef, perr):

,→ 2 """

3 Author: Jakob Ostberg

4 Date: 10-12-2019

5 Compare how the output varies if one peak region is not used in

finding the result

,→

6 Input:

7 Ecal: array containing peak positions in energy

8 pos: array containing estimated peak positions in channels

9 errpos: error in pos elements

10 dataset_full: all data

11 duration_dataset: exposure time

12 pcoef: gain and offset

13 perr: gain and offset error

14 """

15 #two first peak regioins 16 Ecal_8_27 = Ecal[:4] 17 pos_8_27 = pos[:4]

(48)

19 pcoef_8_27 ,pccov_8_27, infodict_8_27, errmsg_8_27, ier_8_27 = optimize.curve_fit(gain_offset,pos_8_27,Ecal_8_27,p0=[7,0.5], sigma = errpos_8_27, absolute_sigma=True, method='lm',

full_output = True)

,→ ,→ ,→

20 perr_8_27 = np.diag(pccov_8_27) 21 #two last peak regioins

22 Ecal_27_74 = Ecal[1:] 23 pos_27_74 = pos[1:]

24 errpos_27_74 = errpos[1:]

25 pcoef_27_74 ,pccov_27_74, infodict_27_74, errmsg_27_74, ier_27_74 =

optimize.curve_fit(gain_offset,pos_27_74,Ecal_27_74,p0=[7,0.5], sigma = errpos_27_74, absolute_sigma=True, method='lm',

full_output = True) ,→ ,→ ,→ ,→ 26 perr_27_74 = np.diag(pccov_27_74) 27 #first and last peak regions 28 Ecal_8_74 = Ecal[0:1] + Ecal[4:] 29 pos_8_74 = pos[0:1] + pos[4:]

30 errpos_8_74 = errpos[0:1] + errpos[4:]

31 pcoef_8_74 ,pccov_8_74, infodict_8_74, errmsg_8_74, ier_8_74 = optimize.curve_fit(gain_offset,pos_8_74,Ecal_8_74,p0=[7,0.5], sigma = errpos_8_74, absolute_sigma=True, method='lm',

full_output = True) ,→ ,→ ,→ 32 perr_8_74 = np.diag(pccov_8_74) 33 34 if showEshift != 0:

35 visualize_shift(dataset_full, pcoef, [perr[0], perr[1]], duration_dataset)

,→

36 visualize_shift(dataset_full, pcoef_8_27, [perr_8_27[0], perr_8_27[1]], duration_dataset)

,→

37 visualize_shift(dataset_full, pcoef_27_74, [perr_27_74[0], perr_27_74[1]], duration_dataset)

,→

38 visualize_shift(dataset_full, pcoef_8_74, [perr_8_74[0], perr_8_74[1]], duration_dataset)

,→ 39

40 global shiftCounter 41 shiftCounter = 0

1 def EnergytoChannel(Evalue): 2 """

(49)

3 convert Energy lists to channel

4 params:

5 Evalue: Energy list

6

7 return:

8 ChValue: Channel list

9 """

10 ChValue = np.zeros_like(Evalue) 11 for i in range(len(Evalue)):

12 ChValue[i] = Gain*Evalue[i] + Offset 13 return ChValue

References

Related documents

Generally, a transition from primary raw materials to recycled materials, along with a change to renewable energy, are the most important actions to reduce greenhouse gas emissions

Both Brazil and Sweden have made bilateral cooperation in areas of technology and innovation a top priority. It has been formalized in a series of agreements and made explicit

För att uppskatta den totala effekten av reformerna måste dock hänsyn tas till såväl samt- liga priseffekter som sammansättningseffekter, till följd av ökad försäljningsandel

Coad (2007) presenterar resultat som indikerar att små företag inom tillverkningsindustrin i Frankrike generellt kännetecknas av att tillväxten är negativt korrelerad över

Från den teoretiska modellen vet vi att när det finns två budgivare på marknaden, och marknadsandelen för månadens vara ökar, så leder detta till lägre

Generella styrmedel kan ha varit mindre verksamma än man har trott De generella styrmedlen, till skillnad från de specifika styrmedlen, har kommit att användas i större

Parallellmarknader innebär dock inte en drivkraft för en grön omställning Ökad andel direktförsäljning räddar många lokala producenter och kan tyckas utgöra en drivkraft

Närmare 90 procent av de statliga medlen (intäkter och utgifter) för näringslivets klimatomställning går till generella styrmedel, det vill säga styrmedel som påverkar