model grids

38 views
Skip to first unread message

Maitraiyee Tiwari

unread,
Oct 4, 2021, 9:46:37 AM10/4/21
to PDR Toolbox
Hi Marc,

I am using plot.overlay_all_ratios method to get an overlay plot of all the individual observed intensities and their corresponding ratios. The problem is that the ratios are constrained to a smaller grid (upto 10^5 in G0 and n) but the individual intensities are still in their original grid (upto 10^7). I've attached the plot. Is it possible to control the grid size by using some keywords? I understand that H2 lines will have a smaller grid size no matter what. 

Another thing, is it possible to add_label in the plots. Could this be controlled by some keywords as well? 

Thanks,
Maitraiyee 
spaghetti-p1-toolbox.png

Marc W. Pound

unread,
Oct 4, 2021, 10:08:05 AM10/4/21
to PDR Toolbox
Hi Maitraiyee

Axis ranges on the plot can be controlled with xlim and ylim keywords, which I see I neglected to document!  (I will fix that).  Example:

plot.overlay_all_ratios(yaxis_unit="Habing",figsize=(5,5),ylim=[10,1E5])

Not sure what you mean by add_label, can you be more specific?

Marc

Maitraiyee Tiwari

unread,
Oct 4, 2021, 10:26:46 AM10/4/21
to Marc W. Pound, PDR Toolbox
Hi Marc,

Thanks!
I just tried the xlim and ylim keywords but I cannot change the grid size for the ratios.
I think the issue is that all the ratios are included only for the smaller model grid. I guess you made this change so that the grid is consistent with H2 lines. The problem is that my CII intensity curve lies above 10^5, so I would like to have the CII/CO and OI/CII ratios also for the larger grid (upto 10^7).  

Sorry about add_label! I want to write some text (like specifying the region's name as shown in the figure attached) on the different plots. How can I do that? Can I use some specific keywords for that?

I also have another request: is it possible to give an input for FIR intensity and have a horizontal line in the overlay plots? I've attached a figure containing such plots (I showed these plots in one of our meetings). 

Regards,
Maitraiyee

--
You received this message because you are subscribed to a topic in the Google Groups "PDR Toolbox" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pdrt/5uDOhbDctHE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pdrt+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdrt/df4fc031-0131-47d4-957a-d0d3b4da18f5n%40googlegroups.com.
overlay-with-fir.png

Marc W. Pound

unread,
Oct 4, 2021, 11:18:58 AM10/4/21
to PDR Toolbox
Ah, now I understand. The brown line OI63/CII_158 and the purple line CII_158/CO3_2 are getting cut off at 10^5 when they should be allowed to use the full range in G0.   That's definitely not the behavior we want.  I will look into it.

Adding arbitrary text is not directly supported with keywords, but you do have access to the underlying matplotlib pyplot instance in a variable called _plt, so you can call matplotlib functions on that.   e.g.

plot.overlay_all_ratios(yaxis_unit="Habing",figsize=(5,5),ylim=[10,1E5])
plot._plt.text(100,100,"this is text")

The WK2006 models don't have a separate FIR intensity FITS file, but I could make one from existing FITS files, e.g. FIR =  CI_609/(CI609/FIR).     Just playing with this in the toolbox (below), shows FIR is a  gradient with G0, no density dependence. Which is why it is a straight line in G0.    So if you don't want to wait for me, you can write out your own FIR.fits as below, manually look up where your horizontal line would be and use the _plt instance again,  plot._plt.plot(10,y,1E7,y,color='k',label='From FIR'), where y is the G0 value corresponding to your FIR.  

from matplotlib import pyplot as plt
ms = ModelSet("wk2006",z=1)
a = ms.get_model("CI_609/FIR")
b  = ms.get_model("CI_609")
c = b/a
plt.imshow(c)
plt.colorbar()

a = ms.get_model("CII_158/FIR")
b  = ms.get_model("CII_158")
c = b/a
plt.imshow(c)  # ok they both look the same!
plt.colorbar()
c.write("/tmp/FIR.fits")

ds9 /tmp/FIR.fits [attached]

Marc
ds9FIR.png

Maitraiyee Tiwari

unread,
Oct 4, 2021, 11:55:43 AM10/4/21
to Marc W. Pound, PDR Toolbox
Hi Marc,

Thanks a lot!

I can add text and lines (I used plot._plt.plot([10,1E7],[y,y]) for a horizontal line) directly now! I already have an FIR intensity map towards RCW49 so I am just calculating G0 from it directly and plotting a horizontal line for the corresponding G0 value.

Regards,
Maitraiyee

Marc W. Pound

unread,
Oct 5, 2021, 9:51:54 AM10/5/21
to PDR Toolbox
Hi Maitraiyee,

Can you give me the notebook or series of commands you used to make this plot, so that I can use it to find and squash the bug?

thanks
Marc


On Monday, October 4, 2021 at 9:46:37 AM UTC-4 Maitraiyee Tiwari wrote:

Maitraiyee Tiwari

unread,
Oct 5, 2021, 9:56:51 AM10/5/21
to Marc W. Pound, PDR Toolbox
Hi Marc,

I am using the attached notebook and the method where the ratios have smaller grid size is: plot.overlay_all_ratios(). 

Regards,
Maitraiyee

--
You received this message because you are subscribed to the Google Groups "PDR Toolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdrt+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdrt/705858de-61a1-4bb1-a448-4dacb816dcd8n%40googlegroups.com.
PDRT_Example_Find_n_G0_Single_Pixel.ipynb

Marc W. Pound

unread,
Oct 5, 2021, 3:34:58 PM10/5/21
to PDR Toolbox
Hi Maitraiyee.

This clipping of all model ratios if H2 lines are included in the observations is a feature not a bug.   The workaround I put in to handle WK2006 H2 line models being on a smaller grid than the rest is that, if H2 is used, all models get clipped to the size of the H2 grid.   This is necessary because we can't calculate chi-square and best fit n,G0 unless all the grids are the same.  There is no way around this.    Luckily Mark is working on full-size H2 models for WK2020 so when those are ready you can switch to the new model set.  

Believe it or not, I have a workaround to the workaround that does not required new code from me, just sneaky use of "private" variables.  I remove the non-H2 model ratios from the plot's copy of the LineRatioFit instance  (plot._tool), add them to the list of Measurements, then after plotting put them back in the LineRatioFit instance.  Attached is the output plot.

# Workaround to plot full extent of ratios that don't have H2 after they've been clipped to run a fit.
# The trick is to pass them in via the measurements keywords.  
# This is possible because Marc was super clever and stores models as class Measurement.
b = [m1,m3,m4,m5]    # reset b in case this cell gets re-run
print(plot._tool._modelratios.keys())
kluge = ["OI_63/CII_158", "CII_158/CO_32"]  # the lines you want to extend on the plot
savek = dict()
for k in kluge:
    b.append(p._observedratios[k])   # add them to measurements
    savek[k] = plot._tool._modelratios.pop(k) # remove them from model ratios
print(plot._tool._modelratios.keys()) # double-check they are gone
plot.overlay_all_ratios(yaxis_unit="Habing",figsize=(15,5),legend=True,measurements=b,loc='upper left',bbox_to_anchor=(1.05,0.9))
#xlim=[10,4E6],ylim=[10,4E6]
plot._plt.text(20,1000000,"random")
plot._plt.text(1E6,1.7E3,"from FIR")
G = 0.9046/(2*1.3E-4) 
plot._plt.plot([10,1E7],[G,G],color='black',linewidth=1)
plot.savefig("spaghetti-random-toolbox.png")
# now put the models back! It's ok that the order has changed.
plot._tool._modelratios.update(savek)
print(plot._tool._modelratios.keys())

Marc
spaghetti-random-toolbox.png
Reply all
Reply to author
Forward
0 new messages