Angstrom to keV axis transformation (xfig example)
Revision as of 13:20, 13 April 2018 by Gokus (talk | contribs) (Created page with " Category:SLxfig ====== Angstrom to keV (and back) coordinate axis transformation ====== The important thing happens in 4 lines at the very beginning; the rest is my usa...")
Angstrom to keV (and back) coordinate axis transformation
The important thing happens in 4 lines at the very beginning; the rest is my usage of the transformation, in case anybody needs it.
require("isisscripts"); require("../common_pars.sl"); %% define coordinate transformation private define aa_to_keV (val, opt){ return _A(val); } xfig_plot_add_transform("aa_to_keV",&aa_to_keV,&aa_to_keV,""); %%%%% variable ll = read_data_from_write_plot("../data/all_unfold_1.dat";no_mod); variable hh = read_data_from_write_plot("../data/all_unfold_0.dat";no_mod); %delta angstrom variable da = 3.125; %variable Major = reverse([1:10]); %variable Minor = reverse([1:100]*0.1); variable Major = [9,8,7,6,5,4,3,2.5,2,1.8,1.6,1.4,1.2,1.1,1,0.9]; variable Minor = [reverse([16:100]*0.1),reverse([8*4:16*4]/40.)]; variable pl1 = xfig_plot_new(width*2,height*(2./3)); pl1.world(1.3,1.7+da,-0.001,0.35); pl1.world2(_A(1.3),_A(1.7+da),-0.001,0.32); pl1.x2axis(;wcs="aa_to_keV",major=Major,minor=Minor); pl1.y2axis(;ticlabels=0); pl1.hplot(ll.lo,ll.val;color=lcol,depth=1); pl1.plot([ll.lo+ll.hi]/2,ll.val,ll.err;sym="point",color=lecol,depth=2); pl1.hplot(hh.lo,hh.val;color=hcol,depth=1); pl1.plot([hh.lo+hh.hi]/2,hh.val,hh.err;sym="point",color=hecol,depth=2); pl1.shade_region([1.5+da,1.7+da,1.7+da,1.5+da], [-0.001,-0.001,0.35,0.35];color="silver",fillcolor="silver"); pl1.xlabel("Wavelength [\AA]"R); pl1.ylabel("Photons cm$^{-2}$ s$^{-1}$ keV$^{-1}$"R); pl1.x2label("Energy [keV]"); %pl1.render("zoom.pdf"); variable pl2 = xfig_plot_new(width*2,height*(2./3)); pl2.world(1.3+da,1.7+2*da,-0.001,0.07); pl2.world2(_A(1.3+da),_A(1.7+2*da),0,0.32); pl2.y2axis(;ticlabels=0); pl2.x2axis(;wcs="aa_to_keV",major=Major,minor=Minor); pl2.hplot(ll.lo,ll.val;color=lcol,depth=1); pl2.plot([ll.lo+ll.hi]/2,ll.val,ll.err;sym="point",color=lecol,depth=2); pl2.hplot(hh.lo,hh.val;color=hcol,depth=1); pl2.plot([hh.lo+hh.hi]/2,hh.val,hh.err;sym="point",color=hecol,depth=2); pl2.shade_region([1.3+da,1.5+da,1.5+da,1.3+da], [-0.001,-0.001,0.35,0.35];color="silver",fillcolor="silver"); pl2.shade_region([1.5+da*2,1.7+da*2,1.7+da*2,1.5+da*2], [-0.001,-0.001,0.35,0.35];color="silver",fillcolor="silver"); pl2.xlabel("Wavelength [\AA]"R); pl2.ylabel("Photons cm$^{-2}$ s$^{-1}$ keV$^{-1}$"R); pl2.x2label("Energy [keV]"); variable pl3 = xfig_plot_new(width*2,height*(2./3)); pl3.world(1.3+2*da,1.7+3*da,-0.001,0.025); pl3.world2(_A(1.3+2*da),_A(1.7+3*da),0,0.32); pl3.y2axis(;ticlabels=0); pl3.x2axis(;wcs="aa_to_keV",major=Major,minor=Minor); pl3.hplot(ll.lo,ll.val;color=lcol,depth=1); pl3.plot([ll.lo+ll.hi]/2,ll.val,ll.err;sym="point",color=lecol,depth=2); pl3.hplot(hh.lo,hh.val;color=hcol,depth=1); pl3.plot([hh.lo+hh.hi]/2,hh.val,hh.err;sym="point",color=hecol,depth=2); pl3.shade_region([1.3+2*da,1.5+2*da,1.5+2*da,1.3+2*da], [-0.001,-0.001,0.35,0.35];color="silver",fillcolor="silver"); pl3.shade_region([1.5+da*3,1.7+da*3,1.7+da*3,1.5+da*3], [-0.001,-0.001,0.35,0.35];color="silver",fillcolor="silver"); pl3.xlabel("Wavelength [\AA]"R); pl3.ylabel("Photons cm$^{-2}$ s$^{-1}$ keV$^{-1}$"R); pl3.x2label("Energy [keV]"); variable pl4 = xfig_plot_new(width*2,height*(2./3)); pl4.world(1.3+3*da,1.7+4*da,-0.001,0.01); pl4.world2(_A(1.3+3*da),_A(1.7+4*da),0,0.32); pl4.y2axis(;ticlabels=0); pl4.x2axis(;wcs="aa_to_keV",major=Major,minor=Minor); pl4.hplot(ll.lo,ll.val;color=lcol,depth=1); pl4.plot([ll.lo+ll.hi]/2,ll.val,ll.err;sym="point",color=lecol,depth=2); pl4.hplot(hh.lo,hh.val;color=hcol,depth=1); pl4.plot([hh.lo+hh.hi]/2,hh.val,hh.err;sym="point",color=hecol,depth=2); pl4.shade_region([1.3+3*da,1.5+3*da,1.5+3*da,1.3+3*da], [-0.001,-0.001,0.35,0.35];color="silver",fillcolor="silver"); %pl4.shade_region([1.5+da*4,1.7+da*4,1.7+da*4,1.5+da*4], % [-0.001,-0.001,0.35,0.35];color="silver",fillcolor="silver"); pl4.xlabel("Wavelength [\AA]"R); pl4.ylabel("Photons cm$^{-2}$ s$^{-1}$ keV$^{-1}$"R); pl4.x2label("Energy [keV]"); xfig_new_vbox_compound(pl1,pl2,pl3,pl4,1).render("zoom.pdf"); print("STACK:"); _print_stack; exit;