The database

The database is installed into a MySQL database. In order to use it, the user needs to learn a few things such as the structure of the database and its intricacies.

Note : Make sure you have the credentials required in order to connect to the database.

First, let's take a look a the database structure. At the moment, it contains 12 tables as shown below. All table are interrelated by column names such as ModelID and ProjectID. Take note of these names as they will come handy later on.



Each table has a purpose and can be explored via the Database tables located in the sidebar on this page.

  • The shock_params table contains all shock parameters used to compute a shock model. This is the most important table in the database.

  • The emis tables contain several emission lines from UV to IR given in unit of ergs/cm^2/s. Each emission line and its related keywords and table can be found using this application.

  • The abundance table contains several abundances sets available in the database.

  • The ion_col_dens contains the ionic column density for several ions.

  • The ion_frac contains the ionic fraction for several ions.

  • The ion_temp contains average ionic temperature for several ions.

Usage

To use the database, you need to learn the Structured Query Language (SQL), its basics and intricacies of data manipulation.

Note : To clear up confusion, the command lines that will follow are SQL code. In order to use the database, you do not need to install the MySQL shell client on your system if your intention is to use Python as your main language. The Setups page is there to show you which Python libraries are required.

The following lines will show you basic SQL code in order to form queries to interact with the MySQL database. Theses queries will become quite useful once embedded within Python code.

For readers unfamiliar with SQL queries, we shall begin with a simple example. Let's say we want to get the emissivity of [N II] 6583 for the following shock parameters :

Grid reference Allen2008
Model type shock only
Abundances set Allen2008_Solar
Pre-shock density 10 cm -3
Transverse magnetic field 1 μG
Shock age < 700 years

We start by indentifying the location of each parameters and its table. The answer to this exercise :

Shock parameter SQL table . Column name
Grid reference shock_params.ref
Model type emis_VI.model_type
Abundances set abundances.name
Pre-shock density shock_params.preshck_dens
Transverse magnetic field shock_params.mag_fld
Age shock_params.time
[N II] 6583 line emis_VI.NII_6563

Notice how we print the table and the parameters (or column name) separated with a "." dot. This is how we select a table and one of its column in SQL.

Take also note that the parameters are located in 3 different tables. This means that we are going to need to join these tables together at some point while writing the SQL request.

Let's write the SQL query. We start by selecting what we want from the database, in this case the emissivity of the [N II] 6583 line :

SELECT emis_VI.NII_6583 AS NII

Take note that all emission lines available can be found on this page.

From the shock_params table, in which all shock parameters are included :

FROM shock_params

We then indicate which table are to be joined :

INNER JOIN emis_VI ON emis_VI.ModelID=shock_params.ModelID
INNER JOIN abundances ON abundances.AbundID=shock_params.AbundID

Followed with the specific parameters wanted :

WHERE shock_params.ref='Allen2008' 
AND emis_VI.model_type='shock' 
AND abundances.name='Allen2008_Solar'
AND shock_params.shck_vel=100
AND shock_params.mag_fld=1
AND shock_params.time<2.208e+10
AND shock_params.preshck_dens=10

Finally, the overall SQL command looks like this :

SELECT emis_VI.NII_6583 AS NII
FROM shock_params
INNER JOIN emis_VI ON emis_VI.ModelID=shock_params.ModelID
INNER JOIN abundances ON abundances.AbundID=shock_params.AbundID
WHERE shock_params.ref='Allen2008' 
AND emis_VI.model_type='shock' 
AND abundances.name='Allen2008_Solar'
AND shock_params.shck_vel=100
AND shock_params.mag_fld=1
AND shock_params.time<2.208e+10
AND shock_params.preshck_dens=10;

Once sent, the database returns :

+-----------------+
| NII             |
+-----------------+
| 0.0000734624664 |
+-----------------+
1 row in set (0.04 sec)

Data manipulation

Most of the time, the user will be interested in line ratios to be compared with their observations. Futhermore, the user will want multiple returns from only one query. Let's see another example in which we are interested at obtaining the ratios of [O III] 5007/Hβ, [N II]/Hα and He II 1640/Hβ for shock velocities between 200 and 1000 km/s for shock models with cut-off temperatures < 1000 K. In addition, we want the age for each shock in years, its distance traveled in parsec for models including shock+precursor. The following shock parameters will be used :

Grid reference Allen2008-sh5
Model type shock+precursor
Abundances set Allen2008_Solar
Pre-shock density 10 cm -3
Transverse magnetic field 1 μG

For start, we can do the ratio directly in SQL on the server side as followed :

SELECT (emis_VI.NII_6583/emis_VI.HI_6563) AS NII_Ha,
       (emis_VI.OIII_5007/emis_VI.HI_4861) AS OIII_Hb,
       (emis_UVC.HeII_1640/emis_VI.HI_4861) AS HeII_Hb

We then specify that we want to get the shock velocities and rounded ages in years and distance travel in parsec :

shock_params.shck_vel,
ROUND((shock_params.time/3.154e+7),0) AS age,
(shock_params.distance/3.086e+18) AS distance

From the shock parameters table :

FROM shock_params

Different tables need to be joined :

INNER JOIN emis_VI ON emis_VI.ModelID=shock_params.ModelID
INNER JOIN emis_UVC ON emis_UVC.ModelID=shock_params.ModelID
INNER JOIN abundances ON abundances.AbundID=shock_params.AbundID

With only models with shock velocity between 200 and 1000 km/s :

WHERE shock_params.shck_vel BETWEEN 200 AND 1000

For the model with shock + precursor :

AND emis_VI.model_type='shock_plus_precursor'

Including the other constraints, the entire SQL query looks like :

SELECT (emis_VI.NII_6583/emis_VI.HI_6563) AS NII_Ha,
       (emis_VI.OIII_5007/emis_VI.HI_4861) AS OIII_Hb,
       (emis_UVC.HeII_1640/emis_VI.HI_4861) AS HeII_Hb,
       shock_params.shck_vel,
       ROUND((shock_params.time/3.154e+7),0) AS age,
       (shock_params.distance/3.086e+18) AS distance
FROM shock_params
INNER JOIN emis_VI ON emis_VI.ModelID=shock_params.ModelID
INNER JOIN emis_UVC ON emis_UVC.ModelID=shock_params.ModelID
INNER JOIN abundances ON abundances.AbundID=shock_params.AbundID
WHERE shock_params.shck_vel BETWEEN 200 AND 1000
AND emis_VI.model_type='shock_plus_precursor'
AND emis_UVC.model_type='shock_plus_precursor'
AND shock_params.ref='Allen2008-sh5' 
AND abundances.name='Allen2008_Solar'
AND shock_params.mag_fld=1
AND shock_params.preshck_dens=10
AND shock_params.cut_off_temp<1e3
ORDER BY shck_vel;

Once the query is sent, the database return different columns associated with the variables declared after the SELECT keywords in the SQL query:

+--------------------+--------------------+---------------------+----------+--------+----------------------+
| NII_Ha             | OIII_Hb            | HeII_Hb             | shck_vel | age    | distance             |        
+--------------------+--------------------+---------------------+----------+--------+----------------------+
| 0.5412544232040827 | 2.4351477122331278 | 0.4707116300718405  |      200 |   1996 | 0.019402763771872975 |
| 0.6046049438870583 | 2.9225876264544155 | 0.6104666728438194  |      225 |   2856 | 0.038462355800388856 |
| 0.6900994340873164 | 3.5693812248226178 | 0.8270964626918348  |      250 |   3737 |  0.06574661697990927 |
|  0.791884622821684 |  4.220619260071799 | 1.0640929688871161  |      275 |   4470 |  0.09598753078418665 |
| 0.8933543439240906 |  4.776287532628963 | 1.3097236994406465  |      300 |   5151 |   0.1329601523007129 |
|  0.994292469872887 |  5.303456965788703 | 1.5470352266097174  |      325 |   5842 |    0.179365939727803 |
| 1.0868982192371404 |  5.843053822383764 | 1.7414103062879605  |      350 |   6616 |  0.23827732987686326 |
| 1.1672385489636927 |  6.438102322334577 | 1.8691615734815796  |      375 |   7583 |  0.31873848023331175 |
| 1.2328347872403056 |  7.108417033000514 |  1.919247315824752  |      400 |   8932 |   0.4382686001296176 |
| 1.2847327337154262 |  7.818588003026863 |  1.912344351116156  |      425 |  10851 |   0.6137083603370058 |
| 1.3253066444479102 |  8.508626028644537 | 1.8788305419865088  |      450 |  13375 |   0.8564478613091381 |
| 1.3547584656014138 |  9.130931771458847 | 1.8372593665371482  |      475 |  16594 |   1.1743565780946208 |
| 1.3759125901947928 |  9.673978843979276 | 1.7986072606306043  |      500 |  20431 |    1.568641963707064 |
| 1.3901610364410883 | 10.132195437051763 | 1.7654128263390847  |      525 |  24783 |   2.0324246921581337 |
| 1.3994990372346165 | 10.514561185182004 |  1.738648272235577  |      550 |  29478 |   2.5570127997407646 |
| 1.4038808469170792 |  10.81838565453228 |  1.715888922396068  |      575 |  34451 |    3.133404180168503 |
|  1.405120702256862 | 11.053529100675483 | 1.6971885096292039  |      600 |  39586 |     3.75450518470512 |
|  1.403642133857342 | 11.223183179763184 | 1.6820273627556512  |      625 |  44810 |    4.412961438755671 |
| 1.3993086862732886 | 11.325110268754596 | 1.6687560952439322  |      650 |  50101 |    5.104211924821776 |
|  1.393171650773638 |  11.36466589486111 | 1.6584238084401268  |      675 |  55410 |    5.827172715489307 |
| 1.3855396270959683 | 11.344210180316148 |  1.650590880927794  |      700 |  60726 |    6.581880103694102 |
|  1.375987082849426 | 11.261460397210394 | 1.6447547059186571  |      725 |  66107 |    7.371219701879456 |
| 1.3653139559269014 | 11.124750622594105 | 1.6415007237858148  |      750 |  71547 |     8.20005411535969 |
|  1.353460890791666 | 10.937765099521778 | 1.6403089203394943  |      775 |  77113 |    9.077625405055088 |
| 1.3415791098248557 | 10.715358710021967 | 1.6423560387739062  |      800 |  82824 |   10.015913804277382 |
| 1.3284770525615843 |   10.4551378727295 | 1.6459521712901428  |      825 |  88814 |   11.030180492546986 |
| 1.3154123723050646 | 10.173510723346448 |  1.652214758031792  |      850 |  95101 |   12.136844134802331 |
| 1.3020702542078093 |  9.874887093978291 | 1.6601652028560818  |      875 | 101793 |   13.353651976668827 |
| 1.2890075428676602 |   9.57459944080803 |  1.670613661409108  |      900 | 108944 |    14.70300874918989 |
| 1.2756177689825179 |  9.271796200464347 | 1.6817486434879465  |      925 | 116672 |    16.20793551523007 |
| 1.2621449577654202 |   8.97902541219172 | 1.6938156804853937  |      950 | 125048 |   17.893663966299417 |
| 1.2489478801922635 |  8.700099640404119 | 1.7058239996955804  |      975 | 134144 |    19.78364063512638 |
|   1.23482603738729 |  8.436288066723694 | 1.7164185628742514  |     1000 | 144044 |   21.896080686973427 |
+--------------------+--------------------+---------------------+----------+--------+----------------------+
33 rows in set (0.04 sec)

To explore the shock parameters available on the database at this moment, it is strongly suggested that you take a look at the parameters explorer.