netcdfファイルから数字を抽出し、ループごとに異なるnetcdfファイルに保存する次のコードがあります。
mapfile Latitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLatitude.txt) #tr is transform from to -s is squeeze. So look in the text files for all the spaces and replace them by newline '/n'
mapfile Longitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLongitude.txt)
echo "length of Lat is ${#Latitude[@]}"
echo "length of Lon is ${#Longitude[@]}"
outputNumber="$(ls -lq *_??????.nc | wc -l)"
echo "the number of output netcdf fles is ${outputNumber}"
valueI=`cat I.txt`
valueJ=`cat J.txt`
arrI=($valueI)
arrJ=($valueJ)
for ((i=1; i<=outputNumber; i++))
do
echo "geknoei$i.nc"
ncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.nc
done
スペースの問題のために入力ファイルを圧縮する必要があり、このコードは機能しなくなりました。必要なものを抽出するために、ループ内のファイルを一度に1つずつ解凍し、ループの終わりに再圧縮するコードを書くことができるかどうか疑問に思います。
だから、おおよそ次のようになります。
mapfile Latitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLatitude.txt) #tr is transform from to -s is search. So look in the text files for all the spaces and replace them by newline '/n'
mapfile Longitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLongitude.txt)
echo "length of Lat is ${#Latitude[@]}"
echo "length of Lon is ${#Longitude[@]}"
outputNumber="$(ls -lq *_??????.nc | wc -l)"
echo "the number of output netcdf fles is ${outputNumber}"
valueI=`cat I.txt`
valueJ=`cat J.txt`
arrI=($valueI)
arrJ=($valueJ)
for ((i=1; i<=outputNumber; i++))
do
echo "geknoei$i.nc"
gunzip *_??????.nc.gz
ncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.nc
gzip *_??????.nc
done
問題は、これはすべてのファイルの圧縮が一度に解放されるため、多くのスペースを占めるということです。一度に 1 つのファイルを解凍すると、使用可能なすべての -unzipped- .nc ファイルから ncrcat コードが抽出されるため、機能しなくなります。
ライン操作を続けながら一度に1つの.ncファイルを解凍するにはどうすればよいですかncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.nc
?