"""
Download spectrum fits files directly from URL links for testing.
"""
import os
import numpy as np
from gpy_dla_detection.read_spec import read_spec, retrieve_raw_spec


def download_ho_2020_spectrum(num_quasars: int = 5):
    """
    Download first N spectra from Ho-Bird-Garnett (2020) catalogue.
    """
    assert num_quasars <= 100

    # first 100 from catalogue
    plates = np.array([6173, 6177, 4354, 6498, 6177, 4216, 6182, 4296, 7134, 6877, 6177,
       4277, 4415, 4216, 4216, 7167, 6177, 4354, 7144, 6177, 7147, 7144,
       6511, 6511, 6151, 4216, 4535, 6182, 7034, 6177, 6151, 6498, 7147,
       6182, 4354, 6177, 6177, 4354, 6879, 6151, 7144, 4354, 4277, 6879,
       6498, 6182, 6879, 4535, 7167, 6879, 4535, 4216, 4216, 4415, 6182,
       6511, 6207, 4216, 6177, 4296, 4277, 7034, 4277, 6152, 6172, 7033,
       4216, 4277, 6498, 7033, 4415, 4535, 6877, 6170, 4296, 6498, 6513,
       6177, 4535, 6151, 4216, 4296, 4296, 7147, 4535, 4296, 7167, 6172,
       4535, 6172, 4216, 7147, 4296, 7167, 4216, 7147, 4296, 6177, 6879,
       7034])
    mjds = np.array([56238, 56268, 55810, 56565, 56268, 55477, 56190, 55499, 56566,
       56544, 56268, 55506, 55831, 55477, 55477, 56604, 56268, 55810,
       56564, 56268, 56574, 56564, 56540, 56540, 56265, 55477, 55860,
       56190, 56564, 56268, 56265, 56565, 56574, 56190, 55810, 56268,
       56268, 55810, 56539, 56265, 56564, 55810, 55506, 56539, 56565,
       56190, 56539, 55860, 56604, 56539, 55860, 55477, 55477, 55831,
       56190, 56540, 56239, 55477, 56268, 55499, 55506, 56564, 55506,
       56164, 56269, 56565, 55477, 55506, 56565, 56565, 55831, 55860,
       56544, 56240, 55499, 56565, 56543, 56268, 55860, 56265, 55477,
       55499, 55499, 56574, 55860, 55499, 56604, 56269, 55860, 56269,
       55477, 56574, 55499, 56604, 55477, 56574, 55499, 56268, 56539,
       56564])

    fiber_ids = np.array([528, 595, 646, 177, 608, 312, 652, 364, 594, 564, 648, 896, 554,
       302, 292, 290, 384, 686, 752, 640, 860, 266,  92,  86,  88, 732,
       680, 342, 358, 386, 936, 844, 171, 338, 702, 584, 393, 709, 439,
        78, 221, 700, 872, 580, 838, 326, 436, 302, 259, 427, 361, 718,
       276, 466, 642, 114, 134, 724, 360, 386, 862, 657, 106,   4, 643,
         2, 290, 152, 157,  14, 580, 315, 440, 573, 390, 158, 892, 366,
       316, 954, 280, 656, 630, 138, 734, 382, 796, 628, 304, 342, 756,
       889, 398, 238, 248, 900, 392, 656, 405, 647])


    for plate, mjd, fiber_id in zip(
        plates[:num_quasars], mjds[:num_quasars], fiber_ids[:num_quasars]
    ):

        filename = "spec-{}-{}-{}.fits".format(plate, mjd, str(fiber_id).zfill(4))

        print(filename)

        if not os.path.exists(filename):
            retrieve_raw_spec(plate, mjd, fiber_id)  # the spectrum at paper

"""
Download spectrum fits files directly from URL links for testing.
"""
import os
import numpy as np
from gpy_dla_detection.read_spec import read_spec, retrieve_raw_spec


def download_ho_2020_spectrum(num_quasars: int = 5):
    """
    Download first N spectra from Ho-Bird-Garnett (2020) catalogue.
    """
    assert num_quasars <= 100

    # first 100 from catalogue
    plates = np.array([6173, 6177, 4354, 6498, 6177, 4216, 6182, 4296, 7134, 6877, 6177,
       4277, 4415, 4216, 4216, 7167, 6177, 4354, 7144, 6177, 7147, 7144,
       6511, 6511, 6151, 4216, 4535, 6182, 7034, 6177, 6151, 6498, 7147,
       6182, 4354, 6177, 6177, 4354, 6879, 6151, 7144, 4354, 4277, 6879,
       6498, 6182, 6879, 4535, 7167, 6879, 4535, 4216, 4216, 4415, 6182,
       6511, 6207, 4216, 6177, 4296, 4277, 7034, 4277, 6152, 6172, 7033,
       4216, 4277, 6498, 7033, 4415, 4535, 6877, 6170, 4296, 6498, 6513,
       6177, 4535, 6151, 4216, 4296, 4296, 7147, 4535, 4296, 7167, 6172,
       4535, 6172, 4216, 7147, 4296, 7167, 4216, 7147, 4296, 6177, 6879,
       7034])
    mjds = np.array([56238, 56268, 55810, 56565, 56268, 55477, 56190, 55499, 56566,
       56544, 56268, 55506, 55831, 55477, 55477, 56604, 56268, 55810,
       56564, 56268, 56574, 56564, 56540, 56540, 56265, 55477, 55860,
       56190, 56564, 56268, 56265, 56565, 56574, 56190, 55810, 56268,
       56268, 55810, 56539, 56265, 56564, 55810, 55506, 56539, 56565,
       56190, 56539, 55860, 56604, 56539, 55860, 55477, 55477, 55831,
       56190, 56540, 56239, 55477, 56268, 55499, 55506, 56564, 55506,
       56164, 56269, 56565, 55477, 55506, 56565, 56565, 55831, 55860,
       56544, 56240, 55499, 56565, 56543, 56268, 55860, 56265, 55477,
       55499, 55499, 56574, 55860, 55499, 56604, 56269, 55860, 56269,
       55477, 56574, 55499, 56604, 55477, 56574, 55499, 56268, 56539,
       56564])

    fiber_ids = np.array([528, 595, 646, 177, 608, 312, 652, 364, 594, 564, 648, 896, 554,
       302, 292, 290, 384, 686, 752, 640, 860, 266,  92,  86,  88, 732,
       680, 342, 358, 386, 936, 844, 171, 338, 702, 584, 393, 709, 439,
        78, 221, 700, 872, 580, 838, 326, 436, 302, 259, 427, 361, 718,
       276, 466, 642, 114, 134, 724, 360, 386, 862, 657, 106,   4, 643,
         2, 290, 152, 157,  14, 580, 315, 440, 573, 390, 158, 892, 366,
       316, 954, 280, 656, 630, 138, 734, 382, 796, 628, 304, 342, 756,
       889, 398, 238, 248, 900, 392, 656, 405, 647])


    for plate, mjd, fiber_id in zip(
        plates[:num_quasars], mjds[:num_quasars], fiber_ids[:num_quasars]
    ):

        filename = "spec-{}-{}-{}.fits".format(plate, mjd, str(fiber_id).zfill(4))

        print(filename)

        if not os.path.exists(filename):
            retrieve_raw_spec(plate, mjd, fiber_id)  # the spectrum at paper

Download spectrum fits files directly from URL links for testing. Download first N spectra from Ho-Bird-Garnett (2020) catalogue. # first 100 from catalogue # the spectrum at paper