This python package is used for space weather research. We try to predict the magnetic field of the magnetic flux rope (MFR) within an interplanetary coronal mass ejection (ICME) at Earth (L1) with (1) machine learning algorithms, and (2) an analogue ensemble method.
by U.V. Amerstorfer, Martin Reiss and C. Möstl, IWF Graz, Austria.
Current status (August 2020): Work in progress!
If you want to use parts of this code for generating results for peer-reviewed scientific publications, please contact us per email (ute.amerstorfer@oeaw.ac.at, christian.moestl@oeaw.ac.at) or via https://twitter.com/chrisoutofspace .
For installation instructions, see below.
conda activate mfrpred
jupyter lab
Run the mfrpred.ipynb notebook in jupyter lab.
Install python 3.7.6 with miniconda:
on Linux:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86.sh
on MacOS:
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh
go to a directory of your choice
git clone https://github.com/uvamerstorfer/MFRpred
Create a conda environment:
conda env create -f environment.yml
conda activate mfrpred
pip install -r requirements.txt
Before running the scripts, you need to download three data files (in total 1.8 GB) from this figshare repository,
https://doi.org/10.6084/m9.figshare.12058065.v7
and place them in the data/ folder.
data/stereoa_2007_2019_sceq_ndarray.p
data/stereob_2007_2014_sceq_ndarray.p
data/wind_2007_2019_heeq_ndarray.p
A catalog for interplanetary coronal mass ejections (HELCATS ICMECAT v2.0) is included in this repo, for updates see:
https://helioforecast.space/icmecat
Please run the scripts in the following order, make sure you have the conda mfrpred environment activated:
mfr_featureSelection.py
mfr_findModel.py
mfr_prediction.py
Run
python mfr_featureSelection.py wind_features.p sta_features.p stb_features.p --features
The first three arguments need to be file names ending in .p (for python pickle) into which the features are saved (at first run of the script) or from which the features are read in, e.g. for Wind its wind_features.p, for STEREO-A sta_features.p, and for STEREO-B stb_features.p, in exactly that order.
--features: set this if features need to be determined. If set, the code will produce a pickle-file with the features and the labels. If --features is not set, then they will be read them from an already existing pickle-file.
--mfr: We try out different features from different regions of the MFR - only sheath features, sheath and MFR features, only MFR features. For the third case, you need to set --mfr. If you want to use MFR features, you also have to specify the variabel feature_hours in the file input.py. This parameter how much time of the MFR is taken for the feature; e.g. feature_hours=0 means only the sheath and no part of the MFR is taken, feature_hours=5 means the first five hours of the MFR are taken.
The features, train and test data sets are saved in pickle-files in an automatically generated subdirectory
mfr_predict/
The corresponding plots are saved in a subdirectory
plots/
To run mfr_findModel.py, two input parameters need to be specified, e.g.:
python mfr_findModel.py train_test_data_fh=5.p model1.p
The first one is the pickle file with the train and test data generated by the previous program in the directory mfr_predict/. The second is the pickle file, into which the selected final model will be saved to. Both files are saved into directory mfr_predict/.
To run mfr_prediction.py, five input parameters need to be specified,e.g.:
python mfr_prediction.py train_test_data_fh=5.p model1.p wind_plot.png sta_plot.png stb_plot.png
- Again the pickle-file with train and test data from mfr_featureSelection.py.
- The pickle-file with the final model from mfr_findModel.py.
- File where plots from analysis of WIND data will be saved to (as .png).
- File where plots from analysis of STA data will be saved to (as .png).
- File where plots from analysis of STB data will be saved to (as .png).
An Analogue Ensemble approach is done with
python AnEn.py