Annual Leaf Cycle

Our Beautiful Living and Breathing Planet

The map is fixed per this article.

# Zoe Phin, 2021/02/13
# File: lai.sh
# To Run: source lai.sh; require; download; fix; animate

require() { sudo apt-get install -y netpbm imagemagick; }

download() {
    list=$(wget -qO- 'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD15A2_M_LAI&date=2016-01-01' | grep '"viewDataset' | cut -f2 -d "'" | tr '\n' ' ')	
    let n=1
    for si in $list; do 
        N=$(printf "%02d" $n)
        wget -O lai$N.jpg "https://neo.sci.gsfc.nasa.gov/servlet/RenderData?si=$si&cs=rgb&format=JPEG&width=750&height=375"
        sleep 1
        let n++
    done
}

fix() { 
    for jpg in `ls -1 lai*.jpg`; do
        pnm=${jpg/.jpg/.pnm}
        echo -e 'P3\n750 375\n255\n' > $pnm
        jpegtopnm $jpg | pnmtoplainpnm | sed 's/  /\n/g' | awk '{printf "%03d %03d %03d ", $1, $2, $3}' | fold -w9000 > .tmp

        cut -c1-300 .tmp > .right
        cut -c300-  .tmp > .left
        paste -d '' .left .right >> $pnm

        pnmtopng $pnm > $jpg
    done
    rm -f *.pnm
}

animate() { convert -delay 25 -loop 0 lai*.jpg animlai.gif; }

Happy Valentines Day!

❤ -Zoe

Published by Zoe Phin

https://phzoe.com

4 thoughts on “Annual Leaf Cycle

    1. This is just a pretty picture. 2016 Leaf Area Index played in a loop, so people can see a typical annual birth and death. Change over time is next. You’re interrsted in knowing pressure by latitude? I can do that. -Z

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: