User Tools

Site Tools


isis:slxfig:elmag

Eletromagnetic spectrum

require("isisscripts");
%%%%%%%%%%%%%%%%%%%%%%%%%%
%Define Constants 

variable wavelength; % m
variable frequency; % 1/s = Hz
variable energy;
variable c = 299792458.0; %m/s
variable h_J = 6.62606957*10^(-34); % J·s
variable h_eV = 4.135667516*10^(-15); % eV*s
variable h_erg = 6.62606957*10^(-27); % erg*s

variable give_wavelength=NULL;
variable give_frequency=22*10^9;
define to_rgb (r, g, b)
{
          return (r << 16) | (g << 8) | b;
}
xfig_new_color ("dark_gray", 0x606060);
xfig_new_color ("orange", 0xEF9F2E);
xfig_new_color ("dark_orange", 0xF97305);
xfig_new_color ("pink", 0xF90580);
xfig_new_color("banana",to_rgb(232,197,0));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
define wavelength2frequency(wavelength)
{
frequency = (1./wavelength)*c;
return frequency;
}
%%%%%%%%%%%%%%%%%
define frequency2wavelength(frequency)
{
wavelength = (1./frequency)*c;
return wavelength;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
define frequency2energy_J(frequency)
{
energy = frequency*h_J;
return energy;
}
%%%%%%%%%%%%%%%%%
define frequency2energy_eV(frequency)
{
energy = frequency*h_eV;
return energy;
}
%%%%%%%%%%%%%%%%%
define frequency2energy_erg(frequency)
{
energy = frequency*h_erg;
return energy;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
define energy2frequency_J(energy)
{
frequency = energy/h_J;
return frequency;
}
%%%%%%%%%%%%%%%%%
define energy2frequency_eV(energy)
{
frequency = energy/h_eV;
return frequency;
}
%%%%%%%%%%%%%%%%%
define energy2frequency_erg(energy)
{
frequency = energy/h_erg;
return frequency;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
define energy2wavelength_J(energy)
{
wavelength = h_J*c/energy;
return wavelength;
}
%%%%%%%%%%%%%%%%%
define energy2wavelength_eV(energy)
{
wavelength = h_eV*c/energy;
return wavelength;
}
%%%%%%%%%%%%%%%%%
define energy2wavelength_erg(energy)
{
wavelength = h_erg*c/energy;
return wavelength;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
define wavelength2energy_J(wavelength)
{
energy = h_J*c/wavelength;
return energy;
}
%%%%%%%%%%%%%%%%%
define wavelength2energy_eV(wavelength)
{
energy = h_eV*c/wavelength;
return energy;
}
%%%%%%%%%%%%%%%%%
define wavelength2energy_erg(wavelength)
{
energy = h_erg*c/wavelength;
return energy;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

variable wavelength_range = [99., 1e-21];
variable plotwidth = 30;
variable wavecol = "black";
variable freqcol="black"; variable energycol = "black"; variable energycol2 = "black";


variable spectrum = xfig_plot_new(plotwidth,20);

spectrum.world(0,20,0,20);
spectrum.x1axis(;off);spectrum.x2axis(;off);spectrum.y1axis(;off);spectrum.y2axis(;off);

variable wave = xfig_plot_new(plotwidth,1);
wave.world(wavelength_range[0],wavelength_range[1],0,1; color=wavecol);
wave.y1axis(;off); wave.y2axis(;off);wave.x2axis(;off);
wave.xlabel("$\lambda$ [m]"R; color= wavecol);
variable major_ticks = [wavelength_range[1]:0:100];
variable minor_ticks= [0:wavelength_range[1]:5];

wave.x1axis(;log, color =wavecol, ticlabel_color=wavecol, major=major_ticks);
%if (give_wavelength!=NULL){wave.plot(give_wavelength, 0.1;sym="+", symcolor="gray");
%wave.xylabel(give_wavelength, 0.5, sprintf("%.2e\n",give_wavelength); color="gray");}
%if (give_frequency!=NULL){wave.plot(frequency2wavelength(give_frequency), 0.1;sym="+", symcolor="gray");
%wave.xylabel(frequency2wavelength(give_frequency), 0.5, sprintf("%.2e\n",frequency2wavelength(give_frequency)); color="gray");}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wave.plot([wavelength_range[0], 10*10^-3], [1, 1];color="goldenrod",forward_arrow, backward_arrow);
wave.xylabel(1,1.4, "RADIO"; color="goldenrod");

wave.add_object(xfig_new_polyline([10*10^-3,300*10^-6 ], [1, 1];forward_arrow, backward_arrow, color="orange2"),
[10*10^-3,300*10^-6 ], [1, 1]) ; wave.xylabel(1.5*10^-3,1.4, "MICROWAVE"; color="orange2");

wave.add_object(xfig_new_polyline([300*10^-6, 750*10^-9], [1, 1];forward_arrow, backward_arrow, color="red2"), 
[300*10^-6, 750*10^-9], [1, 1]); wave.xylabel(10^-5,1.4, "IR"; color="red2");

wave.add_object(xfig_new_polyline([750*10^-9, 390*10^-9], [1, 1]; forward_arrow, backward_arrow,color="purple"),
[750*10^-9, 390*10^-9], [1, 1]) ; wave.xylabel(550*10^-9,1.4, "OP"; color="purple");

wave.add_object(xfig_new_polyline([390*10^-9, 10^-8], [1, 1]; forward_arrow, backward_arrow,color="blue4"),
[390*10^-9, 10^-8], [1, 1]) ; wave.xylabel(5*10^-8,1.4, "UV"; color="blue4");

wave.add_object(xfig_new_polyline([10^-8, 100*10^-12], [1, 1]; forward_arrow, backward_arrow, color="dodgerblue"), 
[10^-8, 100*10^-12], [1, 1]); wave.xylabel(10*10^-10,1.4, "soft"; color="dodgerblue");

wave.add_object(xfig_new_polyline([100*10^-12, 10*10^-12], [1, 1]; forward_arrow, backward_arrow,color="teal"), 
[100*10^-12, 10*10^-12], [1, 1]); wave.xylabel(35*10^-12,1.4, "hard X-rays"; color="teal");
wave.add_object(xfig_new_polyline([10*10^-12, wavelength_range[1]], [1, 1]; forward_arrow, backward_arrow, color="forestgreen"), 
[10*10^-12, wavelength_range[1]], [1, 1]);
wave.xylabel(10^-15,1.4, "$\gamma$-rays"R; color="forestgreen");
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
spectrum.add_object(wave, 0 , 0 , 0 , 0);
%%%%
variable energy_range = xfig_plot_new(plotwidth,1);
energy_range.world(wavelength2energy_eV(wavelength_range[0]),wavelength2energy_eV(wavelength_range[1]),0,1; color=energycol);
energy_range.x1axis(;log, color=energycol, ticlabel_color=energycol); energy_range.y1axis(;off); energy_range.y2axis(;off);energy_range.x2axis(;off);
energy_range.xlabel("E [eV]"R; color=energycol);
%if (give_wavelength!=NULL){energy_range.plot(wavelength2energy_eV(give_wavelength), 0.1;sym="+", symcolor="gray");
%energy_range.xylabel(wavelength2energy_eV(give_wavelength), 0.5, sprintf("%.2e\n",wavelength2energy_eV(give_wavelength)); color="gray");
%}
spectrum.add_object(energy_range, 0, 0, 0 , 1;depth=50);

% variable energy_range2 = xfig_plot_new(plotwidth,1);
% energy_range2.world(wavelength2energy_erg(wavelength_range[0]),wavelength2energy_erg(wavelength_range[1]),0,1; color=energycol2);
% energy_range2.x1axis(;log, color=energycol2, ticlabel_color=energycol2); energy_range2.y1axis(;off); energy_range2.y2axis(;off);energy_range2.x2axis(;off);
% energy_range2.xlabel("E [erg]"R; color=energycol2);
% if (give_wavelength!=NULL){energy_range2.plot(wavelength2energy_erg(give_wavelength), 0.1;sym="+", symcolor="gray");
% energy_range2.xylabel(wavelength2energy_erg(give_wavelength), 0.5, sprintf("%.2e\n",wavelength2energy_erg(give_wavelength)); color="gray");
% }
% spectrum.add_object(energy_range2, 0, 0, 0 , 2);


% OPTIONAL AXIS
variable freq = xfig_plot_new(plotwidth,1);
freq.world(wavelength2frequency(wavelength_range[0]),wavelength2frequency(wavelength_range[1]),0,1; color=freqcol);
freq.x1axis(;log, color=freqcol, ticlabel_color=freqcol); freq.y1axis(;off); freq.y2axis(;off);freq.x2axis(;off);
freq.xlabel("$\nu$ [Hz]"R; color=freqcol);
%if (give_wavelength!=NULL){freq.plot(wavelength2frequency(give_wavelength), 0.1;sym="+", symcolor="gray");
%freq.xylabel(wavelength2frequency(give_wavelength), 0.5, sprintf("%.2e\n",wavelength2frequency(give_wavelength)); color="gray");}
%if (give_frequency!=NULL){freq.plot(give_frequency, 0.1;sym="+", symcolor="gray");
%freq.xylabel(give_frequency, 0.5, sprintf("%.2e\n",give_frequency); color="gray%");}
spectrum.add_object(freq, 0, 0, 0 , 2;depth=50);

%OPTIONAL EMPTY EM SPECTRUM
%spectrum.render("spectrum.pdf");



%OPTIONAL: HESS ENERGY RANGE
#iffalse
%%%%%%%%%%
% ADD GOOD HESS RANGES!
variable new = xfig_plot_new(plotwidth,6.5);
new.world(wavelength2frequency(wavelength_range[0]),wavelength2frequency(wavelength_range[1]),0,4; color=freqcol);
new.x1axis(;log, color=freqcol, ticlabel_color=freqcol,off); new.y1axis(;off); new.y2axis(;off);new.x2axis(;off);


variable r_lo = 100e9;
variable r_hi=100e12;
new.shade_region(energy2frequency_eV(r_lo),energy2frequency_eV(r_hi),0,0.8;world10, fillcolor="black", fill=3,depth=2000);
spectrum.add_object(new, 0, 0, 0,0.25;depth=100);
spectrum.render("spectrum_hess.pdf");
#endiffalse


%%%%%%%%%%
%NEW! ADD GOOD RANGES!

%%%%%%%%%%%%%%%%%%
% ADD RANGES TANAMI
%%
variable new = xfig_plot_new(plotwidth,6.5);
new.world(wavelength2frequency(wavelength_range[0]),wavelength2frequency(wavelength_range[1]),0,4; color=freqcol);
new.x1axis(;log, color=freqcol, ticlabel_color=freqcol,off); new.y1axis(;off); new.y2axis(;off);new.x2axis(;off);

variable tan_lo=8.4e9;
variable tan_hi = 22.3e9;
new.shade_region((tan_lo), (tan_hi),0,0.8;world10, color="black", fill=4,width=0,depth=2000);


%%%%%%%%%%%%%%%%%%
% ADD RANGES OPTICAL
%%
variable ou_lo = 5468e-10;
variable ou_hi=1928e-10;
new.shade_region(wavelength2frequency(ou_lo), wavelength2frequency(ou_hi),0,0.8;world10, width=0,fillcolor="black", fill=4,depth=2000);


%%%%%%%%%%%%%%%%%%
% ADD RANGES XRT
%%
variable x_lo = 0.5e3;
variable x_hi=10e3;

new.shade_region(energy2frequency_eV(x_lo),energy2frequency_eV(x_hi),0,0.8;world10, width=0,fillcolor="black", fill=4,depth=2000);


%%%%%%%%%%%%%%%%%%
% ADD RANGES BAT
%%
variable x_lob = 15e3;
variable x_hib=150e3;

new.shade_region(energy2frequency_eV(x_lob),energy2frequency_eV(x_hib),0,0.8;world10, fillcolor="dodgerblue", fill=30,width=0,depth=2000);



%%%%%%%%%%%%%%%%%%
% ADD RANGES FERMI
%%

variable f_lo = 20e6;
variable f_hi=300e9;

new.shade_region(energy2frequency_eV(f_lo),energy2frequency_eV(f_hi),0,0.8;world10, width=0,fill=4,fillcolor="black",depth=2000);

spectrum.add_object(new, 0, 0, 0,0.25;depth=100);
spectrum.render("spectrum2.pdf");
isis/slxfig/elmag.txt · Last modified: 2013-05-21 13:25 by Felicia Krauss