source: src/param2R.sh @ 158

Last change on this file since 158 was 49, checked in by htune, 8 years ago

Changes to param2R.sh and htune_convertDesign.R which allows when NLHC=1 generate a simple Latin Hypercube design which is much faster than than the k-Extended Latin Hypercube version.

File size: 2.0 KB
Line 
1#!/bin/bash
2
3\rm -f ModelParam.R
4bad=0
5
6if [ $# != 3 ] ; then
7cat <<eod
8Usage : param2R.sh LHCIZE NLHC parameter_file
9eod
10exit
11fi
12
13LHCSIZE=$1
14NLHC=$2
15PARAM_FILE=$3
16
17if [ ! -f $PARAM_FILE ] ; then echo fichier $PARAM_FILE inexistant ; exit ; fi
18#if [ ! $NLHC -ge 3 ] ; then echo NLHC should be '>=' 3 ; exit ; fi
19
20(( NSCMS = LHCSIZE * NLHC ))
21NPARA=`wc -l $PARAM_FILE |awk ' {print $1 }'`
22
23# A automatiser en regardant combien de LES* sont disponibles
24# sur chaque cas.
25
26echo LHCSIZE=$LHCSIZE >> ModelParam.R
27echo NLHC=$NLHC >> ModelParam.R
28echo NSCMS=$NSCMS >> ModelParam.R
29echo NPARA=$NPARA >> ModelParam.R
30
31names=( names lows highs defaults )
32
33for col in  1 2 3 4 ; do
34    (( ii = $col -1 ))
35    liste='param.'${names[$ii]}='c('
36    for val in `awk ' {print $'$col' } ' $PARAM_FILE` ; do
37       if [ $col == 1 ] ; then       
38         liste=$liste'"'$val'",'
39       else
40         liste="$liste$val,"
41       fi
42    done
43   echo $liste | sed -e 's/,$/)/' >> ModelParam.R
44done
45
46
47liste="which.logs<-c("
48ival=0
49ilog=0
50for val in `awk ' { print $5 } ' $PARAM_FILE` ; do
51   (( ival = $ival + 1 ))
52   if [ "$val" = "log" ] ; then
53         liste="$liste$ival,"
54         ilog=1
55   fi
56done
57if [ $ilog == 0 ]; then 
58        echo $liste | sed -e 's/($/()/' >> ModelParam.R
59else
60        echo $liste | sed -e 's/,$/)/' >> ModelParam.R
61fi
62
63cat <<eod>> ModelParam.R
64  param.defaults <- param.defaults[1:NPARA]
65  param.highs <- param.highs[1:NPARA]
66  param.lows <- param.lows[1:NPARA]
67  param.names <- param.names[1:NPARA]
68eod
69
70cat ModelParam.R
71
72echo '=================================================================='
73echo "Generating $NSCMS samples"
74echo '=================================================================='
75Rscript htune_convertDesign.R
76
77#ls -lrt
78
79# On copie les infos de la wave 1 dans le repertoire WAVE1 (1ere vague de l'history matching)
80
81mkdir WAVE1
82# cf plus haut
83mv ModelParam.R WAVE1/
84# Fichier ASCII simulation id - valeur des parametres
85mv Par1D_Wave1.asc WAVE1/
86# Fichier R contenant les mêmes informations
87mv Wave1.RData WAVE1/
88
Note: See TracBrowser for help on using the repository browser.