Skip to content

Latest commit

 

History

History
262 lines (234 loc) · 15.4 KB

README-2021.org

File metadata and controls

262 lines (234 loc) · 15.4 KB

Emission line extraction and analysis from MUSE datasets of HII regions

  • New project [2021-05-04 Tue]
  • Two principal aims:
    1. Analyzing velocity statistics, such as structure functions
      • Collaboration with Javier García Vázquez
    2. Looking for Raman-scattered Balmer wings
      • Collaboration with Mabel Valerdi

Learning to use MPDAF

I have made a series of notebooks

00 Series: short demos of MPDAF functionality

00 00 MPDAF simple demo

00 01 Extract sub-regions

01 Series: longer exercises in extracting line ratio diagnostics

01 00 Line Ratios

  • Notebook: 01-00-line-ratios.ipynb
  • Pure python: 01-00-line-ratios.py
  • Mainly concentrating on the [S II] 6716,31 lines for now
    • Demonstrates a novel (I believe) technique of compensating for uncertainties in the zero-point, which makes use of the known line ratio in the low-density limit
    • Makes use of pandas and seaborn libraries to plot joint distributions of extracted line intensities

02 Series: extraction of the Raman-scattered wings to Balmer lines

02 00 Line Ratios

  • Notebook: 02-00-raman-wings.ipynb
  • Pure python: 02-00-raman-wings.py
  • Yes, we find the wings in NGC 346
    • We have to mask out about 60% of the spatial pixels that are contaminated with stars in order to see it properly
    • Makes use of regions library to select boxes in the image

TODO 03 Series: exercises with velocity moments

N66/NGC 346 in the SMC

  • N66 is the H II region, while NGC 346 is technically the star cluster, but the H II region is also sometimes referred to as this
  • Data are at SMC-NGC-346/ADP.2017-10-16T11_04_19.247.fits
  • Papers on NGC 346
    • Valerdi:2019a Helium abundance
      • Measures physical conditions too:
        • [O III] Te = 13000 K
        • ne = 20-30 ([O II] and [S II]) up to 100 ([Fe III])

Velocity maps

  • Looks like this will be possible for the brighter lines at least
  • There is a problem that seems to be an overzealous background subtraction, which means that some of the lines come out negative
    • We can maybe fix this by adding on the spectrum seen in the darkest corner of the image

Problems with the sky subtraction

  • With the NGC 346 cube, it looks like the pipeline sky subtraction tried to use the science image itself to determine the sky
    • But this is a bad idea since the H II region fills the FOV of the instrument
  • General discussion of sky subtraction in pipeline:
    • Sec 3.9.3 of Weilbacher:2020a
    • MUSE Pipeline Manual
    • External tool to fix up sky subtraction on pipeline-reduced cube
      • ZAP – the Zurich Atmosphere Purge
      • Unfortunately, this seems to require the use of a blank exposure of adjacent sky in cases like ours, and I don’t think that is available

Sample of SMC H II regions from Lopez:2014a

RegionQ(H)R (pc)n (pcc)(Q n)1/3U (IR)Q / 4 π R^2ff
log10pcpccHab(1e9 /cm^2/s)
Orion49.00.25400015.9?2089.442.442
N449.210.25009.37401.270.002
N1151.01455017.12300.400.004
N3049.745.1606.72500.210.005
N4450.61036013.42300.310.003
N4849.975.6507.41400.120.002
N5550.052.4507.92000.300.009
N5950.556.712015.64000.820.004
N7950.264.08010.83200.320.003
N10550.142.213011.83400.590.003
N11950.585.86012.42000.360.004
N14450.471.37012.12700.410.004
N157 (30 Dor)51.798.925050.08604.280.003
N16051.040.012022.93805.220.034
N18050.139.312011.52300.680.005
N19149.030.5503.75000.090.004
N20650.51125011.61400.210.003
DEM S7449.147.9303.4400.050.004
N1349.08.872606.42801.060.007
N1749.126.6704.51200.150.004
N1948.812.41604.71400.340.004
N2249.116.01605.97400.410.004
N3649.944.4607.8800.340.008
N5049.876.3205.0500.090.011
N5148.833.7302.71400.050.006
N6349.023.1603.9900.160.007
N6650.663.910015.83800.810.005
N7148.23.553303.72401.050.010
N7650.055.0708.91300.280.004
N7849.746.1707.15700.200.003
N8049.439.0505.0900.140.005
N8450.2101307.81600.130.005
N9049.530.2505.41100.290.014

Technical issues

TODO Improve the python packaging

  • [2022-04-28 Thu] What I have at the moment with the git subtrees is a bit of a mess
    • For instance, extract.py uses the tetrabloks library
      • Previously it used a relative import, but that only worked when it looked like they were both in the same package
      • But now that I want to make my own whispy package, it is not going to work
  • Ideally, I should just have dependencies on the other packages
    • tetrabloks is the only one that is used by whispy
    • but cloudytab and wcsfile are used by some of the jupyter notebooks
  • Plan of action:
    1. [X] I am going to make a new project for whispy, which will probably use the Hypermodern Python template
      • It can just use tetrabloks as a dependency, using pip to install directly form github
      • But it seems that the repo name is actually multibin-maps
      • So why is it called tetrabloks here? Why did I not document this?
    2. [X] I can also install tetrabloks and the other libraries (wcsfile and cloudytab) directly in my default conda environment
      • doing that now in py39 environment
        pip install git+https://github.com/will-henney/whispy.git
                    
      • This seemed to work, and it pulled in the tetrabloks package too
      • It also upgraded a whole bunch of my other packages, such as numpy and astropy. Hopefully that will not cause me problems.
      • Also, pip called out some inconsistencies it had failed to relove, so I did
        pip install "pillow>=8.3.2"  mimeparse
                    

        and everything seems to be OK

      • [X] So I tried it out in the jupyter console, and I could import them fine
      • [X] Test using these versions in the notebook
      • Tested all except the sky line gaussian fitting, since that will be more involved. But what I have tested is enough to show that the package import mechanism and basic funtionality does work.
    3. [X] If that all works, then I can remove the git submodules entirely
    4. [-] Finally, I should really make a special virtual environment for this project that automatically pulls in the needed dependencies
      • [X] First step towards this is to make a requirements.txt
        • I made this using pigar, which looks for all imports in a project, including jupyter notebooks
        • I installed it with pipx
        • It found most of the libraries, but I had to make some adjustments by hand
      • [ ] Then I have to decide how to make a virtual environment and test it

multibin-maps library included as git subtree

Revisited [2022-04-29 Fri] to sort out the mess

  • This now seems to have been a bad idea on the whole, at least for tetrabloks
    • I tried pushing the tetrabloks subrepo back to the upstream multibin-maps repo on github, but that did not work. I can make a new branch there to receive it, but the history has nothing in common with the actual repo, so I can’t do a pull request to merge them
  • On the other hand, everything worked out fine when I did the same with the cloudytab repo
    • Conclusion is that I must have messed something up with multibin-maps, either when I moved it to the lib folder, or when I renamed it to tetrabloks
  • What I plan to do to fix things is to remove the subtree and then incorporate the changes made directly into the original multibin-maps repo again
  • After that, we can add it as a dependency and let pip, poetry or whatever deal with installing it from github

How I first set it up

  • This was very easy to do with two command using magit
  • I added the github repo for multibin-maps as a remote with M a
    • Corresponding raw git command
      git … remote add -f multibin-maps https://github.com/will-henney/multibin-maps.git
              
  • Then I added it as a subtree with O i a
    • Corresponding raw git command
      git … subtree add --prefix=multibin-maps multibin-maps HEAD
              
  • This made a new commit to this repo for adding the subtree
  • And it also seems to have pulled in all the history from the subtree too
  • Note that I use the same name multibin-maps for
    1. The name of the remote
    2. The prefix (subfolder name)

Ongoing maintenance

  • There is no need to do anything unless we want to update to a newer version
  • In magit use the following commands:
    • O i f to pull new version from upstream
    • O e p to push any local changes back to the upstream multibin-maps repo on github
      • But probably better to just do edits in the upstream repo and then pull them

Another git subtree for cloudytab library

  • I did the same as above, except that I put the subtree prefix to lib/cloudytab
    • Also, I had already moved multibin-maps to the lib folder earlier
  • So the corresponding raw git commands (from M a and O i a) were:
      0 git … remote add -f cloudytab https\://github.com/div-B-equals-0/cloudytab.git
    Updating cloudytab
    Unpacking objects: 100% (14/14), 3.81 KiB | 300.00 KiB/s, done.
    From https://github.com/div-B-equals-0/cloudytab
     * [new branch]      main       -> cloudytab/main
    
      0 git … subtree add --prefix\=lib/cloudytab cloudytab HEAD
    git fetch cloudytab HEAD
    From https://github.com/div-B-equals-0/cloudytab
     * branch            HEAD       -> FETCH_HEAD
     Added dir 'lib/cloudytab'
        
  • [2024-03-13 Wed] I deleted this since it is now on pip-installable, which is a much better solution
    • I got rid of the folder from the command line with git rm -rf lib/cloudytab
    • Then I ditched the remote with M k in magit

And again for the wcsfile library

File maintenance

  • Note that most of this is not necessary most of the time
    • Just make changes to whatever version you like: .md or .py in an editor, or .ipynb in the browser
    • Then the other formats should get automagically updated too
  • I use jupytext to automatically save .py and .md versions of the notebooks
    • Any of the versions can be edited, and then the others can be synced to the last-modified one:
      jupytext --sync FILE
              

      Extract from jupytext help screen:

       --sync, -s            Synchronize the content of the paired representations
                             of the given notebook. Input cells are taken from the
                             file that was last modified, and outputs are read from
                             the ipynb file, if present. (default: False)
              
    • According to the jupytext FAQ, I can just edit the .md or .py version while the notebook is still open in the browser. It will notice that something has changed and offer me the chance to reload it
      • [X] I need to try this out
        • Yes, it actually works. It is better to just force-reload with Cmd-R immediately that you switch back to the browser window
  • We can further convert to a .org file using pandoc. For instance:
    pandoc -o 01-extract-subregions.org 01-extract-subregions.md
        
    • In principle, we could edit the org file and then use pandoc to send it back to md, and then jupytext again to sync up the ipynb version.
      • But I haven’t tried this yet
      • I don’t know whether the jupytext metadata will survive
        • A quick test shows that this metadata doesn’t get written to the .org file by pandoc

Static type checking with mypy

  • I have added type hints to the functions in lib/extract.py
  • [ ] I should really write a bunch of tests too
  • Internal consistency can be checked with mypy:
    mypy --namespace-packages -m extract