CLAWRIM Wiki

The Computational Lab for Advanced Water Resources Informatics and Modeling

User Tools

Site Tools


q_as:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
q_as:start [2024-09-06 09:48 am] abdazzamq_as:start [2024-09-20 08:23 am] (current) hcho
Line 7: Line 7:
  
 How do you append a new column to an object file from a source file? The object file is for a certain coordinate and contains the timeseries of multiple climatic parameters. The source file ''vs.txt'' has wind speed values for all the coordinates in a sequence, which means starting from the n row, the wind speed value for the next day is after 36,217 rows. 36,217 is the total number of coordinates which means that the wind speed needs to be appended in 36,217 files. The object files have naming pattern of ''$lat_$lon_lwave.mtc43''. How do you append a new column to an object file from a source file? The object file is for a certain coordinate and contains the timeseries of multiple climatic parameters. The source file ''vs.txt'' has wind speed values for all the coordinates in a sequence, which means starting from the n row, the wind speed value for the next day is after 36,217 rows. 36,217 is the total number of coordinates which means that the wind speed needs to be appended in 36,217 files. The object files have naming pattern of ''$lat_$lon_lwave.mtc43''.
 +
 +==== Solution ====
 +
 +<file bash doit.sh>
 +#!/bin/sh
 +for i in *.mtc43; do
 +        coor=$(echo $i | sed 's/_/,/; s/_.*//')
 +        (
 +                echo -e "\n\nWind\n(m/s)"
 +                grep $coor vs.txt | cut -d, -f3
 +        ) > tmp.$$
 +        paste $i tmp.$$ > tmp2.$$
 +        mv tmp2.$$ $i
 +done
 +
 +rm -f tmp*.$$
 +</file>
 +
 +===== Extract grid cell IDs =====
 +
 +In {{ :q_as:veg_param_nm_003125deg.zip |}}, extract grid cell IDs.
  
 ===== Files ===== ===== Files =====
  
 {{filelisting}}\\ {{filelisting}}\\
q_as/start.1725637702.txt.gz · Last modified: by abdazzam

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki