1 | #!/bin/bash |
---|
2 | ###################################################################### |
---|
3 | ### Script to modify the orbital parameters of a file "startfi.nc" ### |
---|
4 | ###################################################################### |
---|
5 | |
---|
6 | # Name of the file |
---|
7 | name_file="startfi.nc" |
---|
8 | |
---|
9 | # New values for the orbital parameters |
---|
10 | new_obl=25.18941689 |
---|
11 | new_ecc=0.09340902 |
---|
12 | new_Lsp=251.06881714 |
---|
13 | new_iniLs=0. |
---|
14 | |
---|
15 | |
---|
16 | ###################################################################### |
---|
17 | # Calculate modified values |
---|
18 | if [ ! -f "$name_file" ]; then |
---|
19 | echo "Error: file \"$name_file\" not found!" |
---|
20 | exit 1 |
---|
21 | fi |
---|
22 | year_day=669. |
---|
23 | halfaxe=227.94 |
---|
24 | pi=$(echo "4.*a(1.)" | bc -l) |
---|
25 | degrad=$(echo "180./$pi" | bc -l) |
---|
26 | |
---|
27 | periheli=$(echo "$halfaxe*(1. - $new_ecc)" | bc -l) |
---|
28 | aphelie=$(echo "$halfaxe*(1. + $new_ecc)" | bc -l) |
---|
29 | |
---|
30 | tan=$(echo "s(0.5*$new_Lsp/$degrad)/c(0.5*$new_Lsp/$degrad)" | bc -l) |
---|
31 | zx0=$(echo "-2.*a($tan*sqrt((1. - $new_ecc)/(1. + $new_ecc)))" | bc -l) |
---|
32 | if [ $(echo "$zx0 <= 0." | bc -l) -eq 1 ]; then |
---|
33 | zx0=$(echo "$zx0 + 2.*$pi" | bc -l) |
---|
34 | fi |
---|
35 | peri_day=$(echo "$year_day*(1. - ($zx0 - $new_ecc*s($zx0))/(2.*$pi))" | bc -l) |
---|
36 | |
---|
37 | ztheta=$(echo "($new_iniLs - $new_Lsp)/$degrad" | bc -l) |
---|
38 | tan=$(echo "s(0.5*$ztheta)/c(0.5*$ztheta)" | bc -l) |
---|
39 | zx0=$(echo "2.*a($tan*sqrt((1. - $new_ecc)/(1. + $new_ecc)))" | bc -l) |
---|
40 | xref=$(echo "$zx0 - $new_ecc*s($zx0)" | bc -l) |
---|
41 | new_inisol=$(echo "$peri_day + $xref*$year_day/(2.*$pi)" | bc -l) |
---|
42 | if [ $(echo "$new_inisol < 0." | bc -l) -eq 1 ]; then |
---|
43 | new_inisol=$(echo "$new_inisol + $year_day" | bc -l) |
---|
44 | fi |
---|
45 | if [ $(echo "$new_inisol >= $year_day" | bc -l) -eq 1 ]; then |
---|
46 | new_inisol=$(echo "$new_inisol - $year_day" | bc -l) |
---|
47 | fi |
---|
48 | |
---|
49 | # Update the netCDF file |
---|
50 | # controle(15) = periheli ! min. Sun-Mars distance (Mkm) ̃206.66 |
---|
51 | # controle(16) = aphelie ! max. Sun-Mars distance (Mkm) ̃249.22 |
---|
52 | # controle(17) = peri_day ! date of perihelion (sols since N. spring) |
---|
53 | # controle(18) = obliquit ! Obliquity of the planet (deg) ̃23.98 |
---|
54 | # controle(3) = day_ini + int(time) ! initial day |
---|
55 | ncap2 -O -s "controle(17)=$new_obl" \ |
---|
56 | -s "controle(14)=$periheli" \ |
---|
57 | -s "controle(15)=$aphelie" \ |
---|
58 | -s "controle(16)=$peri_day" \ |
---|
59 | -s "controle(2)=$new_inisol" \ |
---|
60 | $name_file $name_file |
---|
61 | |
---|
62 | echo "In \"$name_file\":" |
---|
63 | echo "New obliquit = $new_obl" |
---|
64 | echo "New eccentricity = $new_ecc -> new periheli = $periheli" |
---|
65 | echo " -> new aphelie = $aphelie" |
---|
66 | echo "New Lsp = $new_Lsp -> new peri_day = $peri_day" |
---|
67 | echo "New initial Ls = $new_iniLs -> New initial sol = $new_inisol" |
---|
68 | echo "Done!" |
---|