galsci / pysm

PySM 3: Sky emission simulations for Cosmic Microwave Background experiments
https://pysm3.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
33 stars 23 forks source link

New model employing a mix of Commander and GNILC templates #176

Closed giuspugl closed 4 months ago

giuspugl commented 5 months ago

As agreed at the last PanexGS call , I made a new pysm3 model employing a mix of Commander and GNILC templates, respectively for the Bd and Td maps I use the former , the latter is for the amplitudes templates (small scales included with log poltens formalism).

You should be able to access my nb on gist https://gist.github.com/giuspugl/ca15b12d3143f97792d4021a822b1cca

please feel free to comment.

1cosmologist commented 4 months ago

@zonca I tried to run PySM with the config file from Giuseppe's notebook and encountered the following error:

Traceback (most recent call last):
  File "/pscratch/sd/s/shamikg/AoA_mapbased/code/fg_sim.py", line 66, in <module>
    fg_sky.append(sm.Sky(nside=nside, component_config="d10commander_giuseppe.cfg", output_unit='uK_CMB'))
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/pysm3/sky.py", line 165, in __init__
    self.components += create_components_from_config(
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/pysm3/sky.py", line 43, in create_components_from_config
    output_component = component_class(
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/pysm3/models/dust.py", line 72, in __init__
    self.I_ref = self.read_map(
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/pysm3/models/template.py", line 77, in read_map
    return read_map(
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/pysm3/models/template.py", line 357, in read_map
    filename = utils.RemoteData().get(path)
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/pysm3/utils/data.py", line 57, in get
    raise e
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/pysm3/utils/data.py", line 52, in get
    full_path = data.get_pkg_data_filename(filename, show_progress=True)
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/astropy/utils/data.py", line 752, in get_pkg_data_filename
    return download_file(
  File "/pscratch/sd/s/shamikg/cmbenv/master-0.0.1/conda/lib/python3.10/site-packages/astropy/utils/data.py", line 1563, in download_file
    raise urllib.error.URLError(
urllib.error.URLError: <urlopen error Unable to open any source! Exceptions were {'https://portal.nersc.gov/project/cmb/pysm-data/dust_gnilc/gnilc_dust_template_nside2048.fits': <HTTPError 404: 'Not Found'>, 'http://www.astropy.org/astropy-data/dust_gnilc/gnilc_dust_template_nside2048.fits': <HTTPError 404: 'Not Found'>}>

@brandonshensley managed to run Giuseppe's notebook without any changes. I ended up changing map_I = "dust_gnilc/gnilc_dust_template_nside{nside}_2023.02.10.fits" which is taken from the current values of map_I for model d10 from presets.cfg. Are we still having a mismatch of versions of template cache?

zonca commented 4 months ago

@1cosmologist is right, @giuspugl might be using an older version of the templates present in their cache. You should always check presets.cfg for the right filenames, so that this problem won't occur anymore:

https://github.com/galsci/pysm/blob/main/pysm3/data/presets.cfg#L152-L154

1cosmologist commented 4 months ago

@zonca Perhaps the answer is to purge the pysm local cache when upgrading from version <3.4.0, as a part of the install process.

zonca commented 4 months ago

@zonca Perhaps the answer is to purge the pysm local cache when upgrading from version <3.4.0, as a part of the install process.

I'd rather not mess with the user data. Moreover, the problem just occurred because @giuspugl specifically requested an older version of the templates, and those happened to be in the cache. In case they just run dx10, that automatically picks up the right templates.

zonca commented 4 months ago

I'll close this issue, even closed it is a useful reference for the future. @giuspugl @1cosmologist I assume you just used these maps for testing and results are not going into the paper. If this is not true, we should consider making this model an official PySM model. Please reopen if this is the case.