I have a tab separated model input file I would like to vary for an ensemble analysis formatted similar to this
input.txt
/* Preciptation in mm */
10 30 40 50 23
### Species description
*** sp_name LMA wsg
abies_lasiocarpa 2 0.5
abies_grandis 2.5 0.4
larix_occidentalis 1.5 0.3
I have another file of multipliers with one per line such as this
multipliers.txt
0.5
0.6
0.7
I would like to generate a series of new input files where one field (wsg) is multiplied by a single multiplier from the second file. In this example there would be 3 new files corresponding to the 3 multipliers. The output files would look like the following:
file1.txt (wsg * 0.5)
/* Preciptation in mm */
10 30 40 50 23
### Species description
*** sp_name LMA wsg
abies_lasiocarpa 2 0.25
abies_grandis 2.5 0.2
larix_occidentalis 1.5 0.15
file2.txt (wsg * 0.6)
/* Preciptation in mm */
10 30 40 50 23
### Species description
*** sp_name LMA wsg
abies_lasiocarpa 2 0.3
abies_grandis 2.5 0.24
larix_occidentalis 1.5 0.18
file3.txt (wsg * 0.7)
/* Preciptation in mm */
10 30 40 50 23
### Species description
*** sp_name LMA wsg
abies_lasiocarpa 2 0.35
abies_grandis 2.5 0.28
larix_occidentalis 1.5 0.21
This seems like something that could be done using awk and a for loop, but my knowledge of awk is not at the level necessary to execute this task. How should I approach this?
multipliers.txt
? The answer greatly affects how to implement a solution. – Ed Morton Feb 12 at 22:27