Trend of Chlorophyll in Water

NASA has a data product that tracks the amount of chlorophyll in water across the globe.

I downloaded all available 2003-2020 (inclusive) monthly data in 1440 by 720 pixel format to see how chlorophyll in water changes over time.

This task is actually not easy because there’s a lot of missing data (black pixels). I decided to use only non-missing pixels that are persistent across all 216 months. There are 27998 of them. That’s 2.7% of the globe.

This is a map of these persistent locations:

Omnipresent Chlorophyll Measures

Here’s the trend for these locations:

Change (2003,2020): 2.942 %
Linear Regression Change (2003-2020): 2.736 %

That’s a nice positive change.

I then thought about it some more, and decided to do it on a monthly basis. Here’s a map of all persistent January pixels for all 18 years:

And here is All July:

Here is the linear regression trend for every month:

01 -0.046 %
02 +4.834 %
03 +8.112 %
04 +1.008 %
05 -7.842 %
06 -1.898 %
07 +1.130 %
08 +5.267 %
09 +6.818 %
10 +1.999 %
11 +5.372 %
12 +3.786 %

Avg: +2.378 %

Enjoy 🙂 -Zoe

Update

Some more data:

Note the rise in 1997 to 1998. That was a very warm season. Look at the rise! How can anyone be against global warming, except the cult of death?

Code

# Zoe Phin, 2021/03/24
# File: chloro.sh
# Run: source chloro.sh; require; download; convert; chloro; cmap; plot; change; annual; months

require() { sudo apt-get install -y gmt gnuplot; }

download() {
    rm -f *.csv
    for y in {2003..2020}; do
        wget -qO- "https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MY1DMM_CHLORA&year=$y"
    done | awk -F\' '/"viewDataset/{print $4" "$2}' > sets.csv 
    awk '{print "wget -O "$1".csv \"https://neo.sci.gsfc.nasa.gov/servlet/RenderData?si="$2"&cs=rgb&format=CSV&width=1440&height=720\""}' sets.csv > sets.sh
    bash sets.sh
}

convert() {
    for f in $(ls -1 2*.csv); do
        cat $f | tr ',' '\n' > ${f/.csv/.dat}
    done
    ls -1 *.dat | xargs paste -d ' ' | nl > .db
    grep -v '99999.0' .db > chloro.db
    rm -f *.dat .db
}

chloro() {
    awk 'BEGIN {
        a=6378.137; e=1-6356.752^2/a^2; r=atan2(0,-1)/180
    } { 
        l = sprintf("%d", ($1-1)/1440)/4-89.875
        A = (a*r)^2*(1-e)*cos(r*l)/(1-e*sin(r*l)^2)^2
        SA += A
        for (i=2; i<=NF; i++) 
            S[i] += $i*A
    } END {
        for (m in S)
            printf("%.5f\n", S[m]/SA)
    }' chloro.db | awk '{
        printf "%.2f %.5f\n", 2003+(NR-1)/12+1/24, $1
    }' > chloro.csv
}

cmap() {
    awk '{
        lat = sprintf("%d", ($1-1)/1440)/4-89.875
        lon = ($1-1)%1440*360/1440-180
        printf "%.3f %.2f\n", lat, lon
    }' chloro.db > cmap.csv
    echo "set term png size 560,360
        set margin 4,2,2,1
        set nokey 
        set yrange [-90:90]
        set xrange [-180:180]
        set ytics 30; set xtics 30
        set grid ytics xtics
        plot 'cmap.csv' u 2:(-\$1) t 'Chlorophyll' pt 5 ps 0.1 lc rgb '#00CC00'
    "| gnuplot > cmap.png 
}

plot() { 
    echo -n "Linear Regression Slope: "
    cat chloro.csv | gmt gmtregress -Fp -o5 | awk '{printf "%.5f /year\n", $1}'
    cat chloro.csv | gmt gmtregress | sed 1d | awk '{printf "%.2f %.5f %.5f\n", $1, $2, $3}' > plot.csv
    echo "set term png size 740,620
        set key outside top center horizontal
        set mxtics 2; set mytics 2
        set format y '%.2f'
        set xrange [2003:2021]
        set grid xtics mxtics ytics mytics
        plot 'plot.csv' u 1:2 t 'Chlorophyll (mg/m³)' w lines lw 2 lc rgb '#00CC66',\
                     '' u 1:3 t 'Linear Regression' w lines lw 3 lc rgb '#006666'		
    "| gnuplot > chloro.png 
}

change() {
    echo -n "Change (2003,2020): "
    awk '{Y[substr($1,1,4)]+=$2/12} END { printf "%.3f %\n", (Y[2020]/Y[2003]-1)*100 }' plot.csv
    echo -n "Linear Regression Change (2003-2020): "
    awk '{Y[substr($1,1,4)]+=$3/12} END { printf "%.3f %\n", (Y[2020]/Y[2003]-1)*100 }' plot.csv
}

annual() {
    awk '{Y[substr($1,1,4)]+=$2/12} END { for (y in Y) printf "%s %.5f\n", y, Y[y]}' chloro.csv
}

months() {
    for m in {01..12}; do
        echo -n "$m "
        for f in $(ls -1 2*-$m-*.csv); do
            cat $f | tr ',' '\n' > ${f/.csv/.dat}
        done
        ls -1 2*-$m-*.dat | xargs paste -d ' ' | nl > .db
        grep -v '99999.0' .db | tee chloro.db | awk 'BEGIN {
            a=6378.137; e=1-6356.752^2/a^2; r=atan2(0,-1)/180
        } { 
            l = sprintf("%d", ($1-1)/1440)/4-89.875
            A = (a*r)^2*(1-e)*cos(r*l)/(1-e*sin(r*l)^2)^2
            SA += A
            for (i=2; i<=NF; i++) 
                S[i] += $i*A
        } END {
            for (m in S)
                printf("%.7f\n", S[m]/SA)
        }' | awk '{
        printf "%.2f %.5f\n", 2003+(NR-1), $1
        }' | gmt gmtregress | sed 1d | awk '{Y[substr($1,1,4)]+=$3/12} END { printf "%+.3f %\n", (Y[2020]/Y[2003]-1)*100 }'
    done | tee .seas
    awk '{S+=$2} END { printf "\nAvg: %+.3f %\n", S/NR }' .seas
}

Published by Zoe Phin

https://phzoe.com

2 thoughts on “Trend of Chlorophyll in Water

  1. A warming globe with higher CO2 concentration means that the planet can sustain more life, right? I don’t understand the doom and gloom at all. I told my kids that the only thing that may be worrisome to me is that we may get bigger bugs and bigger hoards of bugs. They don’t like mosquito bites.

    Like

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: