dgahle / mast-upgrade-baysar-analysis

Scripts to analyse the atomic line spectrum measured from the MAST-Upgrade tokamak.
MIT License
0 stars 1 forks source link

Need functionality to automate downloads from Open-ADAS (API) #2

Closed dgahle closed 1 year ago

dgahle commented 1 year ago

I have already added this code to a branch of ColRadPy and can use it in this repo.

Need to add an algorithm that will create the URL to pull from. Will have to account for:

url: str = f"https://open.adas.ac.uk/download/adf04/adas][6/mom97_ls][c{charge}.dat"
adf04_file: str = f"mom97_ls#c{charge}.dat"
adf04_files.append(adf04_file)
adf04_path: Path = INPUT_PATH / adf04_file
if not exists(adf04_path):
    with request.urlopen(url) as f:
        adf04: str = f.read().decode('utf-8')
        with open(adf04_path, "x") as f_adf04:
            f_adf04.write(adf04)

https://github.com/johnson-c/ColRadPy/blob/examples-refactor/examples/ion_bal.py

dgahle commented 1 year ago

One way could be to download the HTML of the search results page (e.g. https://open.adas.ac.uk/adf15?element=c&charge=1&wave_min=&wave_max=&resolveby=file&searching=1) and then inspect the <div id="searchresults"> object. The HTML for that object is shown below and the last column contains the links.

<div id="searchresults">
    <h3>9 ADF15 files found</h3>
        <table summary="ADF15 Search Results">
            <tbody>
                <tr><th>Ion</th><th>Minimum Wavelength</th><th>Maximum Wavelength</th><th>File Details</th></tr>
                <tr><td>C<sup>+</sup></td><td>426.6Å</td><td>1987.9Å</td><td><a class="filelink" href="detail/adf15/pec96][c/pec96][c_pjr][c1.dat"><span>ADF<strong>15</strong></span> pec96#c_pjr#c1.dat</a></td></tr>
                <tr><td>C<sup>+</sup></td><td>426.6Å</td><td>1987.9Å</td><td><a class="filelink" href="detail/adf15/pec96][c/pec96][c_pju][c1.dat"><span>ADF<strong>15</strong></span> pec96#c_pju#c1.dat</a></td></tr>
                <tr><td>C<sup>+</sup></td><td>641.8Å</td><td>9880.7Å</td><td><a class="filelink" href="detail/adf15/pec93][c/pec93][c_pju][c1.dat"><span>ADF<strong>15</strong></span> pec93#c_pju#c1.dat</a></td></tr>
                <tr><td>C<sup>+</sup></td><td>641.8Å</td><td>9880.7Å</td><td><a class="filelink" href="detail/adf15/pec93][c/pec93][c_pjr][c1.dat"><span>ADF<strong>15</strong></span> pec93#c_pjr#c1.dat</a></td></tr>
                <tr><td>C<sup>+</sup></td><td>641.8Å</td><td>9880.7Å</td><td><a class="filelink" href="detail/adf15/pec93][c/pec93][c_llr][c1.dat"><span>ADF<strong>15</strong></span> pec93#c_llr#c1.dat</a></td></tr>
                <tr><td>C<sup>+</sup></td><td>641.8Å</td><td>9880.7Å</td><td><a class="filelink" href="detail/adf15/pec93][c/pec93][c_llu][c1.dat"><span>ADF<strong>15</strong></span> pec93#c_llu#c1.dat</a></td></tr>
                <tr><td>C<sup>+</sup></td><td>687.2Å</td><td>7234.4Å</td><td><a class="filelink" href="detail/adf15/ionelec/ionelec_pec][c1.dat"><span>ADF<strong>15</strong></span> ionelec_pec#c1.dat</a></td></tr>
                <tr><td>C<sup>+</sup></td><td>2138.4Å</td><td>9906.5Å</td><td><a class="filelink" href="detail/adf15/pec96][c/pec96][c_vsu][c1.dat"><span>ADF<strong>15</strong></span> pec96#c_vsu#c1.dat</a></td></tr>
                <tr><td>C<sup>+</sup></td><td>2138.4Å</td><td>9906.5Å</td><td><a class="filelink" href="detail/adf15/pec96][c/pec96][c_vsr][c1.dat"><span>ADF<strong>15</strong></span> pec96#c_vsr#c1.dat</a></td></tr>                </tbody></table>
</div>
dgahle commented 1 year ago

This issue is going to be closed with specific functionality additions to the OpenADAS API should be individual tasks.