[esp-r] Re: sed
Achim Geissler
achim.geissler at intergga.ch
Thu Jul 2 19:14:00 BST 2015
Dear Arianna,
as I was the one to give you this idea, I guess I will have to give some pointers. But keep in mind that this must be considered a hack and you will likely need to learn a bit about writing shell scripts. You can find ample information and coding examples for sed and bash scripts in the internet.
You have zones named “bath", “bedroom1", “entrance" and so on. Correspondingly, you have entries in the .cfg file of the type
*con ../zones/bath.con
…
*con ../zones/bedroom1.con
and so on. Now, the sequence (e.g. in a bash shell script which runs your model), the lines
# Change construction file to CON
new_bath_con=“*con ../zones/bath_${CON}.con # construction"
new_bed1_con=“*con ../zones/bedroom1_${CON}.con # construction"
cp ${VAR}.cfg temp.cfg
sed 's%.*con ../zones/bath_.*%'"${new_bath_con}”'%
s%.*con ../zones/bedroom1_.*%'"${new_bed1_con}”'%' temp.cfg > ${VAR}.cfg
rm temp.cfg
should replace the existing con file entries (for bath and bedroom1) in .cfg by the new ones “bath_${CON}.con” and “bedroom1_${CON}" in the file ${VAR}.cfg (I haven’t tried this exact example, but other similar ones). The “$” stuff are variables in loops inside your bash script. Basically, you would need to pre-define your various .con files, e.g. by numbering them like bath_1.con, bedroom1_1.con and so on (and the initial .cfg would need to have entries of this type!). Via a list
CONLIST=“1 2 3”
and the loop
foreach CON in $CONLIST
do
<< here the sed changing is done >>
<< here you call bps and do your simulation >>
done
you can run through a series of simulations. I expect many people would prefer using python or perl for this.
And, as written before, you of course always have the option of managing a row of models - probably quicker first time round, but in the long run vastly less elegant and also a lot more prone to errors in my experience. Of course, it would be easier if the switching of constructions and other files etc. were reliable when running ESP-r in text mode from a script which I have also found not to be the case (which originally lead me down the above described road).
Best
Achim
> On 02 Jul 2015, at 16:08, Arianna Sdei <A.Sdei2 at brighton.ac.uk> wrote:
>
> Dear All,
>
> have you used sed to modify construction files via scripting? I am having troubles when I modify construction files to see the effects of increased external insulation. I am not 100% sure that ESP-r is actually recognizing the changes I make and I don't trust 100% the results I get at the moment. I would like to try sed to make sure that my results are rigorous, let me know if you can help.
>
> Thank you,
> regards.
> Arianna
>
> ___________________________________________________________
> This email has been scanned by MessageLabs' Email Security
> System on behalf of the University of Brighton.
> For more information see http://www.brighton.ac.uk/is/spam/ <http://www.brighton.ac.uk/is/spam/>
> ___________________________________________________________
> _______________________________________________
> esp-r mailing list
> esp-r at lists.strath.ac.uk <mailto:esp-r at lists.strath.ac.uk>
> http://lists.strath.ac.uk/mailman/listinfo/esp-r <http://lists.strath.ac.uk/mailman/listinfo/esp-r>
achim.geissler at intergga.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.strath.ac.uk/archives/esp-r/attachments/20150702/52625cc0/attachment.html
More information about the esp-r
mailing list