gammasim / simtools

Tools and applications for the Simulation System of the CTA Observatory.
https://gammasim.github.io/simtools
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

Validate telescope positions in layout files #120

Closed RaulRPrado closed 2 years ago

RaulRPrado commented 3 years ago

Telescope positions should match the ones from https://gitlab.cta-observatory.org/cta-science/cta-science/-/blob/master/Array%20Element%20Positions/CTAN_ArrayElements_Positions.md

GernotMaier commented 2 years ago

Not entirely sure which telescope positions are meant here, possibly those in https://github.com/gammasim/gammasim-tools/tree/master/data/layout ? There is is also a outdated file for prod5 positions: https://github.com/gammasim/gammasim-tools/blob/master/data/layout/telescope_positions-South-Prod5.ecsv

I don't see that telescope_positions-South-Prod5.ecsv and telescope_positions-North-Prod5.ecsv is used and we agreed on getting those positions from the database.

Suggest to remove both files and close this issue.

orelgueta commented 2 years ago

I agree. Generally we cannot validate any positions at the moment anyway considering they are still changing on a regular basis.

GernotMaier commented 2 years ago

Good - but removing the files telescope_positions-South-Prod5.ecsv and telescope_positions-North-Prod5.ecsv results in errors in testing test_simulator.py::test_setFileLocations.

I have to check what I did wrong, but that looks like a horrible hidden dependency...

GernotMaier commented 2 years ago

Ok, I am struggling to understand the logic here. The constructor

arraySimulator = Simulator(label=label, simulator="simtel", configData=arrayConfigData)

with

def arrayConfigData(tmp_test_directory):
    return {
        "dataDirectory": str(tmp_test_directory) + "/test-output",
        "primary": "gamma",
        "zenith": 20 * u.deg,
        "azimuth": 0 * u.deg,
        "viewcone": [0 * u.deg, 0 * u.deg],
        # ArrayModel
        "site": "North",
        "layoutName": "1LST",
        "modelVersion": "Prod5",
        "default": {"LST": "1"},
        "MST-01": "FlashCam-D",
    }

as defined in tests/unit_tests/test_simulator.py is trying to read the file data/layout/telescope_positions-South-Prod5.ecsv.

This must be a bug, as the layoutName is 1LST, so we should read only telescope_positions-South-1LST.ecsv.

This happens in:

I try and dig further where the information on the layout name is lost - but is my understanding right that we should only read the 1LST layout file? Quite confusing.

orelgueta commented 2 years ago

But when you run test_simulator.py::test_setFileLocations you call two constructors, the arrayConfigData you pasted above and another one

@pytest.fixture
def showerConfigData():
    return {
        "dataDirectory": ".",
        "site": "South",
        "layoutName": "Prod5",
        "runList": [3, 4],
        "runRange": [6, 10],
        "nshow": 10,
        "primary": "gamma",
        "erange": [100 * u.GeV, 1 * u.TeV],
        "eslope": -2,
        "zenith": 20 * u.deg,
        "azimuth": 0 * u.deg,
        "viewcone": 0 * u.deg,
        "cscat": [10, 1500 * u.m, 0],
    }

Which calls the Prod5 southern site. So it makes sense it reads that file.

GernotMaier commented 2 years ago

Ah, you are right.

After looking into it a bit more: I suggest not to remove those files but simply rename them. These are the only layout files with all telescope types and mixed layouts.

I don't think the positions are actually the final prod5 positions, and we should make sure that this is not mixed up. For testing, this could be any name, e.g., : telescope_positions-North-TestLayout.ecsv

orelgueta commented 2 years ago

Yes I agree, let's rename them as test layouts. We also need the final Prod5 layouts in the DB. At the moment they are saved only as the CORSIKA list (as far as I remember), but we need them also in this ecsv format.