AstarVienna / ScopeSim_Templates

GNU General Public License v3.0
2 stars 4 forks source link

Not able to set the magnitude for I band #49

Closed carmeloarci closed 1 year ago

carmeloarci commented 1 year ago

Hi. I´trying to set source for MICADO testing. I wanted to set a specific magnitude in the MICADO filter. What I wanted is to define a star source to have a XX magnitude in the YY filter of MICADO.

However I understood that "stars" in scopesim_templates calls Spextrum (stars.py) 260 spectra = [Spextrum(modelclass=pickles_lib[spt]).scale_to_magnitude(filter_curve=filter_name, amplitude=zero) scaling of the magnitude using a specific filter_name. I don't understand to which specific filter the call is pointing to, J,H,Ks seem to work, I-long doesn´t giving back an error message. I'm not able to understand if this J,H,Ks are MICADO or filters in other photometric systems.

Here some code.

import scopesim as scope import scopesim_templates as scope_tp

spec_types = ["A0V"] mags = np.array([15.0,16.0,17.0]) x = np.array([0,2,2.5]) y = np.array([0,0,-1]) spec_arr = spec_types * mags.size

filter_name="J" stars_j = scope_tp.stars(filter_name,mags,spec_arr,x,y) filter_name="H" stars_h = scope_tp.stars(filter_name,mags,spec_arr,x,y) filter_name="Ks" stars_ks = scope_tp.stars(filter_name,mags,spec_arr,x,y)

filter_name="Generic/Bessell.I"

filter_name="I-long" stars_i = scope_tp.stars(filter_name,mags,spec_arr,x,y)

oczoske commented 1 year ago

I'm not very familiar with scopesim_templates and speXtra, but playing around a bit I find that stars_i = scope_tp.stars("elt/micado/I-long", mags, spec_arr, x, y) seems to work. The documentation on the filters is https://spextra.readthedocs.io/en/latest/filters.html - it's far from perfect, though. The download messages indicate that J and H are 2MASS filters; strangely, there is no download message for Ks.

hugobuddel commented 1 year ago

I'm still familiarizing myself with speXtra, but I learned a thing or two when investigating some problems in the past.

These short names are defined in https://github.com/AstarVienna/speXtra/blob/master/database/default_filters.yml , so "J" should be "etc/J", etc. The filter systems (in the above case "etc") are defined in https://github.com/AstarVienna/speXtra/blob/master/database/index.yml , so "etc" is "ESO ETC standard filters", which apparently from 2MASS.

This probably makes sense. ScopeSIM_Templates is not MICADO-specific, so it should probably not default to MICADO filters. Defaulting to the ESO ETC standard filters seems reasonable.

Oliver gave the command to get the MICADO-specific filters, which can all be found in https://github.com/AstarVienna/speXtra/blob/master/database/filter_systems/micado/index.yml

As for downloading, there are three places speXtra can look for files:

I added the last option this month, because the SVO was down for days. Now all the tests and notebooks in ScopeSIM and the IRDB will work even if the SVO is down again. (In my opinion they should al work without internet; that is not yet the case).

I hope this answers your question @carmeloarci . However, I'd like to keep this issue open as you having to ask this here is an indication that the documentation is not sufficiently clear, so we have to improve on that.

carmeloarci commented 1 year ago

I'm not very familiar with scopesim_templates and speXtra, but playing around a bit I find that stars_i = scope_tp.stars("elt/micado/I-long", mags, spec_arr, x, y) seems to work. The documentation on the filters is https://spextra.readthedocs.io/en/latest/filters.html - it's far from perfect, though. The download messages indicate that J and H are 2MASS filters; strangely, there is no download message for Ks.

I'm trying, with no success..

spec_types = ["A0V"]
mags = np.array([15.0,16.0,17.0])
x  = np.array([0,2,2.5])
y  = np.array([0,0,-1])
spec_arr = spec_types * mags.size
filter_name="I-long"
stars_i = scope_tp.stars(filter_name,mags,spec_arr,x,y)

['A0V'] filter I-long doesn't exist

filter_name="elt/micado/I-long"
stars_i = scope_tp.stars(filter_name,mags,spec_arr,x,y)

_['A0V'] updating/loading 'filter_systems/elt/micado/index.yml' HTTPError: HTTP Error 404: Not Found. requested URL: 'https://homepage.univie.ac.at/miguel.verdugo/database/filter_systems/elt/micado/index.yml'_

I crosschecked the version of scopesim I 'm using (0.5.6):

pip install --upgrade scopesim
Requirement already satisfied: scopesim in /home/carmelo/.conda/envs/idp/lib/python3.7/site-packages (0.5.6)

TRYING TO FIND A SOLUTION....

I also checked in the spextra data folder as suggested by @hugobuddel :

(idp) [carmelo@dyno photo-test]$ more /home/carmelo/.conda/envs/idp/lib/python3.7/site-packages/spextra/data/config.yml 
database_url: https://homepage.univie.ac.at/miguel.verdugo/database/
data_dir: Null
remote_timeout: 30.0
default_data_dir: spextra      # this makes sure it falls back to .astropy/cache/spextra.

This suggests that probably there is still some issue on the dowload part.

I then installed directly from github

pip install git+https://github.com/AstarVienna/spextra

Installing collected packages: speXtra Attempting uninstall: speXtra Found existing installation: speXtra 0.30 Uninstalling speXtra-0.30: Successfully uninstalled speXtra-0.30 Successfully installed speXtra-0.33

and now the suggested filter_name="elt/micado/I-long" works well

hugobuddel commented 1 year ago

Thanks @carmeloarci .. This problem occurred because pip upgrade scopesim did not upgrade spextra, while it should. I've created https://github.com/AstarVienna/ScopeSim/issues/199 to track that issue.

Your solution of installing from github is sufficient. That should have installed the latest version of speXtra. Just pip upgrade spextra should have worked as well. But to reiterate, it is a bug that you had to do that; upgrading ScopeSim should have upgraded speXtra automatically.

However, sometimes these Python environments get messed up anyway, so it can be worthwhile to occasionally just create a fresh environment.

oczoske commented 1 year ago

@carmeloarci , @hugobuddel Can this be closed?

hugobuddel commented 1 year ago

Well, I just recreated this environment, and it is still not working nicely. It is essentially still necessary to do

pip install -U ScopeSim ScopeSim_Templates speXtra

to fully upgrade ScopeSim and related tools.

Nevertheless, I believe we should close this issue, because @carmeloarci 's direct problem is addressed.

I believe it should be possible to upgrade everything simply by doing

pip install -U ScopeSim

The best way to achieve that would be, in my opinion, to split ScopeSim as it is in a library (ScopeSim_Core) and an application (ScopeSim). The application could then depend on ScopeSim_Templates etc, but the library would not. This has several other benefits, and I've created https://github.com/AstarVienna/ScopeSim/issues/256 for that.

@carmeloarci Please reopen it if you think this should be kept open for now.

carmeloarci commented 1 year ago

I believe it can stay closed. I tested it: and works. Downloading missing filters.

import scopesim as scope
import scopesim_templates as scope_tp
import numpy as np

spec_types = ["A0V"]
mags = np.array([15.0,16.0,17.0])
x = np.array([0,2,2.5])
y = np.array([0,0,-1])
spec_arr = spec_types * mags.size

filter_name="J"
stars_j = scope_tp.stars(filter_name,mags,spec_arr,x,y)
filter_name="H"
stars_h = scope_tp.stars(filter_name,mags,spec_arr,x,y)
filter_name="Ks"
stars_ks = scope_tp.stars(filter_name,mags,spec_arr,x,y)
#filter_name="Generic/Bessell.I"
filter_name="I"
stars_i = scope_tp.stars(filter_name,mags,spec_arr,x,y)