def test_main():
    tel = TelescopeModel(site='north',
                         telescopeModelName='lst-1',
                         modelVersion='p3',
                         label='test_camera_eff')
    ce = CameraEfficiency(telescopeModel=tel)
    ce.simulate(force=True)
    ce.analyze(force=True)

    # Plotting Cherenkov
    plt.figure(figsize=(8, 6), tight_layout=True)
    ax = plt.gca()
    ax.set_xlabel('wl')
    ax.set_ylabel('eff')

    ce.plot('cherenkov')

    plotFileCherenkov = io.getTestPlotFile('camera_eff_cherenkov.pdf')
    plt.savefig(plotFileCherenkov)

    # Plotting NSB
    plt.figure(figsize=(8, 6), tight_layout=True)
    ax = plt.gca()
    ax.set_yscale('log')
    ax.set_xlabel('wl')
    ax.set_ylabel('eff')

    ce.plot('nsb')

    plotFileNSB = io.getTestPlotFile('camera_eff_nsb.pdf')
    plt.savefig(plotFileNSB)
Ejemplo n.º 2
0
def test_plot_image():
    version = 'prod3'
    label = 'test-astri'
    configData = {
        'sourceDistance': 10 * u.km,
        'zenithAngle': 20 * u.deg,
        'offAxisAngle': [0, 2.5, 5.0] * u.deg
    }

    tel = TelescopeModel(site='south',
                         telescopeModelName='sst-D',
                         modelVersion=version,
                         label=label)

    ray = RayTracing(telescopeModel=tel, configData=configData)

    ray.simulate(test=True, force=True)
    ray.analyze(force=True)

    # Plotting images
    for ii, image in enumerate(ray.images()):
        plt.figure(figsize=(8, 6), tight_layout=True)
        ax = plt.gca()
        ax.set_xlabel('X [cm]')
        ax.set_ylabel('Y [cm]')
        image.plotImage(psf_color='b')
        plotFile = io.getTestPlotFile('test_plot_image_{}.pdf'.format(ii))
        plt.savefig(plotFile)
Ejemplo n.º 3
0
def test_integral_curve():
    version = 'prod4'
    label = 'lst_integral'

    configData = {
        'sourceDistance': 10 * u.km,
        'zenithAngle': 20 * u.deg,
        'offAxisAngle': [0] * u.deg
    }

    tel = TelescopeModel(site='north',
                         telescopeModelName='mst-FlashCam-D',
                         modelVersion=version,
                         label=label)

    ray = RayTracing(telescopeModel=tel, configData=configData)

    ray.simulate(test=True, force=True)
    ray.analyze(force=True)

    # Plotting cumulative curve for each image
    plt.figure(figsize=(8, 6), tight_layout=True)
    ax = plt.gca()
    ax.set_xlabel('radius [cm]')
    ax.set_ylabel('relative intensity')
    for im in ray.images():
        im.plotCumulative(color='b')
    plotFile = io.getTestPlotFile('test_cumulative_psf.pdf')
    plt.savefig(plotFile)
Ejemplo n.º 4
0
def test_plot_1D():

    logger.debug('Testing plot1D')

    xTitle = 'Wavelength [nm]'
    yTitle = 'Mirror reflectivity [%]'
    headersType = {'names': (xTitle, yTitle), 'formats': ('f8', 'f8')}
    title = 'Test 1D plot'

    testDataFile = io.getTestDataFile('ref_200_1100_190211a.dat')
    dataIn = np.loadtxt(testDataFile, usecols=(0, 1), dtype=headersType)

    # Change y-axis to percent
    if '%' in yTitle:
        if np.max(dataIn[yTitle]) <= 1:
            dataIn[yTitle] = 100 * dataIn[yTitle]
    data = dict()
    data['Reflectivity'] = dataIn
    for i in range(5):
        newData = np.copy(dataIn)
        newData[yTitle] = newData[yTitle] * (1 - 0.1 * (i + 1))
        data['{}%% reflectivity'.format(100 * (1 - 0.1 * (i + 1)))] = newData

    plt = visualize.plot1D(data, title=title, palette='autumn')

    plotFile = io.getTestPlotFile('plot_1D.pdf')
    if plotFile.exists():
        plotFile.unlink()
    plt.savefig(plotFile)
    if not plotFile.exists():
        raise RuntimeError('Did not create {}!'.format(plotFile))

    logger.debug('Produced 1D plot ({}).'.format(plotFile))

    return
Ejemplo n.º 5
0
def test_rx():
    version = 'current'
    label = 'test-lst'

    configData = {
        'sourceDistance': 10 * u.km,
        'zenithAngle': 20 * u.deg,
        'offAxisAngle': [0, 2.5, 5.0] * u.deg
    }

    tel = TelescopeModel(site='north',
                         telescopeModelName='lst-1',
                         modelVersion=version,
                         label=label)

    ray = RayTracing(telescopeModel=tel, configData=configData)

    ray.simulate(test=True, force=True)
    ray_rx = copy(ray)

    ray.analyze(force=True)
    ray_rx.analyze(force=True, useRX=True)

    # Plotting d80
    plt.figure(figsize=(8, 6), tight_layout=True)
    ax = plt.gca()
    ax.set_xlabel('off-axis')
    ax.set_ylabel('d80')

    ray.plot('d80_deg', marker='o', linestyle=':')
    ray_rx.plot('d80_deg', marker='s', linestyle='--')

    plotFilePSF = io.getTestPlotFile('d80_test_rx.pdf')
    plt.savefig(plotFilePSF)

    # Plotting effArea
    plt.figure(figsize=(8, 6), tight_layout=True)
    ax = plt.gca()
    ax.set_xlabel('off-axis')
    ax.set_ylabel('eff. area')

    ray.plot('eff_area', marker='o', linestyle=':')
    ray_rx.plot('d80_deg', marker='s', linestyle='--')

    plotFileArea = io.getTestPlotFile('effArea_test_rx.pdf')
    plt.savefig(plotFileArea)
Ejemplo n.º 6
0
def test_single_mirror(plot=False):

    # Test MST, single mirror PSF simulation
    version = 'prod3'
    configData = {'mirrorNumbers': list(range(1, 5)), 'singleMirrorMode': True}

    tel = TelescopeModel(site='north',
                         telescopeModelName='mst-FlashCam-D',
                         modelVersion=version,
                         label='test-mst')

    ray = RayTracing(telescopeModel=tel, configData=configData)
    ray.simulate(test=True, force=True)
    ray.analyze(force=True)

    # Plotting d80 histogram
    plt.figure(figsize=(8, 6), tight_layout=True)
    ax = plt.gca()
    ax.set_xlabel('d80')

    ray.plotHistogram('d80_cm', color='r', bins=10)
    plotFile = io.getTestPlotFile('d80_hist_test.pdf')
    plt.savefig(plotFile)
Ejemplo n.º 7
0
def test_plot_table():

    logger.debug('Testing plotTable')

    title = 'Test plot table'

    tableFile = io.getTestDataFile('Transmission_Spectrum_PlexiGlass.dat')
    table = ascii.read(tableFile)

    plt = visualize.plotTable(table,
                              yTitle='Transmission',
                              title=title,
                              noMarkers=True)

    plotFile = io.getTestPlotFile('plot_table.pdf')
    if plotFile.exists():
        plotFile.unlink()
    plt.savefig(plotFile)
    if not plotFile.exists():
        raise RuntimeError('Did not create {}!'.format(plotFile))

    logger.debug('Produced 1D plot ({}).'.format(plotFile))

    return