<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Imports and configuration
Note
Step1:  Specify the path to your JCMsuite installation directory here. You can skip this later if you have a configuration file.
Step2:  Prepare
Creating a JCMProject
Step3:  Set the keys that are necessary to translate the JCM template files.
Step4:  Initialize a SimulationSet. We ignore the configured storage here and save everything in the current working dir.
Step5:  Make a schedule
Step6:  Define a processing function
Step7:  Solve
Is your machine multicore? Than uncomment this statement and allow yourself some more computation power.
Step8:  Run your simulations. The results will be appended to the HDF5 store.
Step9:  Plot
Step10:  Write the data to CSV.
<ASSISTANT_TASK:>
Python Code:
import sys
sys.path.append('..')
import os
import numpy as np
Explanation: Imports and configuration
Note: It is assumed that impatient people do not have a configuration file yet. You can learn on configuration files in the Setting up a configuration file notebook. 
Since the parent directory, which contains the pypmj module, is not automatically in our path, we need to append it before.
End of explanation
import pypmj as jpy
jpy.import_jcmwave('/path/to/your/JCMsuite/installation/directory')
Explanation: Specify the path to your JCMsuite installation directory here. You can skip this later if you have a configuration file.
End of explanation
project = jpy.JCMProject('../projects/scattering/mie/mie2D')
Explanation: Prepare
Creating a JCMProject: It is assumed that you run this notebook in the a subfolder of the folder structure shipped with pypmj. If this raises an Exception, make sure that the path to the mie2D project is correct.
End of explanation
mie_keys = {'constants' :{}, # <-- can be anything, but is not looped over and not stored in the HDF5 store
            'parameters': {}, # <-- everything that needs to be stored, but is not in layout.jcmt
            'geometry': {'radius':np.linspace(0.3, 0.5, 40)}} # <-- same as before, but layout.jcmt-relevant
Explanation: Set the keys that are necessary to translate the JCM template files.
End of explanation
simuset = jpy.SimulationSet(project, mie_keys)
Explanation: Initialize a SimulationSet. We ignore the configured storage here and save everything in the current working dir.
End of explanation
simuset.make_simulation_schedule()
Explanation: Make a schedule: this checks which simulations need to be run and sorts them depending on their geometry.
End of explanation
def read_scs(pp):
    results = {} #must be a dict
    results['SCS'] = pp[0]['ElectromagneticFieldEnergyFlux'][0][0].real
    return results
Explanation: Define a processing function: all post process results are passed to this function automatically. It must return a dict with your results.
End of explanation
# simuset.resource_manager.resources['localhost'].set_m_n(4,2)
Explanation: Solve
Is your machine multicore? Than uncomment this statement and allow yourself some more computation power.
End of explanation
simuset.run(processing_func=read_scs)
Explanation: Run your simulations. The results will be appended to the HDF5 store.
End of explanation
%matplotlib inline
data = simuset.get_store_data().sort_values(by='radius')
data.plot(x='radius', y='SCS', title='Results of the simulation')
Explanation: Plot
End of explanation
simuset.write_store_data_to_file() # default is results.csv in the storage folder
Explanation: Write the data to CSV.
End of explanation
<END_TASK>