Swarm mission collects data about the Earth’s magnetic field. The geomagnetosphere topic is also investigated by the Institute of Experimental Physics, which makes it more likely to be investigated within diploma students’ theses. The activities include usage of the geomagnetospheric models, downloading and visualization of the actual data, and comparison between models and reality.

## Lecture slides

## Lab activities

- All files are available in the git repository stored in the faculty’s Gitlab server.
- The address of the project is the following:

https://git.kpi.fei.tuke.sk/svd/lab-swarm

### Setup

**TASK #1: Token setup and creation of request.**

Register an account at https://vires.services/oauth/accounts/signup/ and according to the instructions at https://viresclient.readthedocs.io/en/latest/access_token.html get access token. Study sample source code at https://viresclient.readthedocs.io/en/latest/api.html

### Obtaining information about the data

**TASK #2: Print information about all available …**

- Collections
- Models
- Available measurements

## Data acquisition

**TASK #3: Change the source code as specified.**

- Copy the source code of sample request from https://viresclient.readthedocs.io/en/latest/api.html
- Modify the request code to obtain high-resolution magnetospheric data from the alpha satellite, the documentation for the parameters of the swarm request is at https://viresclient.readthedocs.io/en/latest/available_parameters.html
- Get scalar and vector data from measurements, the collection documentation is at https://earth.esa.int/web/guest/missions/esa-eo-missions/swarm/data-handbook/level-1b-product-definitions#MAGX_LR_1B_Product
- Get data from IGRF, MF7, LCS-1 and CHAOS models
- Set the data collection step every 30 seconds “PT30S” https://en.wikipedia.org/wiki/ISO_8601#Durations (a smaller value means more data to download, you may experiment with this value).
- Get data from the date range 15.3.2015 00:00 to 20.3.2015 00:00 https://en.wikipedia.org/wiki/ISO_8601
- Convert the data to a dataframe from which you will get the values in the next step

### Data parsing

**TASK #4: Parse specified data from dataframe.**

Get lists containing: Measured intensity of magnetic field, modeled intensity of magnetic field according to IGRF and CHAOS models, modeled intensity of crustal magnetic fields from at least one source, latitude and longitude.

f_measured=???

f_igrf=???

f_chaos=???

f_mf7=???

f_lcs1=???

latitude=???

longitude=???

radius=???

Parse the individual components from the magnetic field vector of the IGRF model.

igrf=???

???

igrf_x=???

igrf_y=???

igrf_z=???

Parse the individual components from the magnetic field vector.

measured=???

???

measured_x=???

measured_y=???

measured_z=???

### Plotting the modelled geomagnetic fields

**TASK #5: Implement function as specified.**

- Implement a function that takes in arrays containing latitude, longitude, values at points specified by them and a boolean mask array. This function should return arrays of latitude, longitude and values all filtered by the input mask.
**def**filterArrayByMask(x, y, data, m):

**TASK #7: Plot the components of modelled geomagnetic vector.**

- Using the implemented methods, plot the intensities of the components of the magnetic field modeled by the IGRF model

### Data filtering

**TASK #8: Plot the negative intensities of the components of the magnetic field modeled by the IGRF model.**

- Using the implemented methods, plot the negative intensities of the components of the magnetic field modeled by the IGRF model.

### Calculation of scalar intensities from vector components

**TASK #9: Calculate scalar intensities from vector components and plot them.**

- Calculate the total magnetic field strength of the modeled IGRF and the measured magnetic field from the given components and plot it on a map.
- Do the rendered graphs look the same? How are they different? Draw a graph of the measured values so that the range of values is similar to the modeled one.

### Comparison of measured and modelled values

**TASK #10: Compare the measured and modeled values.**

- Calculate arrays of percentual deviations of modelled to measured values for IGRF and CHAOS models and plot them.
- Use calculated arrays and plot map that shows places where IGRF model is more precise
- Use calculated arrays and plot map that shows places where CHAOS model is more precise
- Print mean values of ratio deviations.

### Histogram and scatter plots of modelled results deviations

**TASK #11: Plot histogram and scatter plots.**

- Using matplotlib.pyplot.hist (https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.hist.html) and matplotlib.pyplot.scatter (https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.scatter.html) functions, plot calculated ratios on Y axis and latitudes on X axis.

### Visualizing large deviations

**TASK #12: Plot the filtered data capturing large deviation (more than 1 percent)**

- Plot only places where absolute ratio deviations are more than 1 percent for IGRF model.
- Plot only places where absolute ratio deviations are more than 1 percent for CHAOS model.

**TASK #13: Plot histogram and scatter plots of large deviations (absolute ratios of over 1 percent of measured to modeled values)**

- Use the same functions as in TASK #11 to plot absolute ratios of over 1 percent of measured to modeled values. Which model accumulated the highest deviations?