Mercurial > repos > astroteam > crbeam_astro_tool
comparison makeSpecE2.sh @ 0:f40d05521dca draft default tip
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit de01e3c02a26cd6353a6b9b6f8d1be44de8ccd54
author | astroteam |
---|---|
date | Fri, 25 Apr 2025 19:33:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f40d05521dca |
---|---|
1 #!/bin/bash | |
2 #prints normalized spectrum dN(E)/dE * E^2 | |
3 inidir=$PWD | |
4 | |
5 if [ $# -lt 1 ] | |
6 then | |
7 echo "usage ./makeSpecE2.sh file" | |
8 exit 1 | |
9 fi | |
10 | |
11 if [ -f $1 ] | |
12 then | |
13 ofile=$1.spec | |
14 cat $1 | awk '!/^($|[[:space:]]*#)/{ printf("%.1f %g\n",log($1)/log(10)+0.05,$2)}' | sort -g -k 1 | awk '{ if($1!=PREV&&NR>1) printf("%g %g %d\n",PREV,SUM,SUMN); if($1!=PREV||NR==1) {SUM=0; SUMN=0;} SUM=SUM+$2; SUMN=SUMN+1; PREV=$1; } END {printf("%g %g %d\n",PREV,SUM,SUMN)}' | awk 'NF==3 { E=10^($1-0.05); printf("%g %g %d\n", E, $2*E/(10^0.05-10^(-0.05)),$3)}'>$ofile | |
15 else | |
16 echo $1 not found | |
17 exit 1 | |
18 fi | |
19 |