File:Ccsm4 july temperature south and middle europe lgm 1.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 1,236 × 1,052 pixels, file size: 7.12 MB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: Avearege temperature of July in C, Iast Glacial maximum, CCM4.
Date
Source Own work
Author Merikanto

This plot is based on WorldClim 1,4 CCSM4 LGM downscaled 2.5 min data

Hijmans, R.J., S.E. Cameron, J.L. Parra, P.G. Jones and A. Jarvis, 2005. Very high resolution interpolated climate surfaces for global land areas. International Journal of Climatology 25: 1965-1978.

WorldClim 1.4 LGM CCSM4 month 7 data is averaged from tn and tx vairables and divided by 10 with QGIS raster calculator. Data is cropped with R script. Visualization is produced with Anaconda Python, Matplotlib sctipt.


R script to cut raster

library(raster)

outname1<-"lgmcc_europe_tk7.nc"

r1<-raster("D:/datavarasto/cclgmtk7.nc")

plot(r1)


  1. mosaik1 <- merge(r1,r2,r3,r4)

mosaik1<-r1


  1. france
  2. ext1 <- extent(-4,8, 39, 51)
  3. dordogne
  4. ext1 <- extent(-2,4,42 , 48)
  1. europe

ext1 <- extent(-15,40,30 , 70)

kropped1<-crop(mosaik1, ext1)

plot(kropped1)

crs(kropped1) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

writeRaster(kropped1, filename=outname1, format="CDF", overwrite=TRUE)

Anaconda Python code to visualize raster image to .svg

    1. netcdf plotting program
    2. lat, lon, zvar!
  1. -*- coding: utf-8 -*-

from mpl_toolkits.basemap import Basemap, cm import matplotlib.pyplot as plt from netCDF4 import Dataset as open_ncfile import numpy as np

    1. preprocess with GMT 5.4
  1. gmt grdcut tk7_gauss1.nc -Gwest_europe_tk7.nc -R-10/50/30/60
  1. netcdf infile name, variable names
  2. lon, lat, z vars

infilename='lgmcc_europe_tk7.nc' zvarlabel='GDAL.Band.Number.1' latvarlabel='latitude' lonvarlabel='longitude'

  1. labels

legtitle="T July avg.°C (LGM, CCSM4)" plottitle="Temperature of July (Last Glacial Maximum, WorldClim 1.4 CCSM4 )"

    1. output

outimage="out.svg" outpdf="out.pdf"

  1. cmap

kolormap='jet'

  1. kolormap='Spectral_r'
  2. kolormap='gist_rainbow_r'
  3. kolormap='rainbow'
    1. cmap min, max

zeta=-15 zetb=25

lona=-15 lonb=40 lata=30 latb=70


latdx=5 londy=5

deltazc=1.5 deltazd=5 dpi = 70

  1. -- open netcdf file

nc = open_ncfile(infilename)

var = nc.variables[zvarlabel][:,:]

var2=np.flipud(var)


lat = nc.variables[latvarlabel][:] lon = nc.variables[lonvarlabel][:]

  1. -- create figure and axes instances

fig = plt.figure(figsize=(1100/dpi, 1100/dpi), dpi=dpi) ax = fig.add_axes([0.1,0.1,0.8,0.9])

  1. map = Basemap(projection='cyl',llcrnrlat=lata,urcrnrlat= latb,\
  2. resolution='h', llcrnrlon=lona,urcrnrlon=lonb)

map = Basemap(projection='cyl',llcrnrlat=lata,urcrnrlat= latb,\

             resolution='h',  llcrnrlon=lona,urcrnrlon=lonb)


map.drawcoastlines(color='darkblue') map.drawrivers(color='blue')

  1. map.drawstates()
  2. map.drawcountries()
  1. kolorado=('black','black','black','black','black','black','black','black','black','black','black','black','black','black','black','black')

kolorado=( (0.0, 0.0, 0.5),(0.0, 0.0, 0.5),(0.0, 0.0, 0.5),(0.0, 0.0, 0.5), (0.0, 0.0, 0.5),(0.0, 0.0, 0.5),(0.0, 0.0, 0.5),(0.0, 0.0, 0.5))



map.drawparallels(np.arange(lata, latb,latdx),labels=[1,0,0,0],fontsize=20) map.drawmeridians(np.arange(lona,lonb,londy),labels=[0,0,0,1],fontsize=20)

x, y = map(*np.meshgrid(lon,lat))


clevs = np.arange(zeta,zetb,deltazc) dlevs = np.arange(zeta,zetb,deltazd)

  1. xx, yy = np.meshgrid(lon, lat)
  2. map.pcolormesh(xx, yy, var)


maplot1=map.imshow(var2, cmap=kolormap, vmin=zeta, vmax=zetb)

plt.rc('lines', linewidth=0.5, color='#000000')

cnplot = map.contour(x,y,var,dlevs,colors=kolorado)

  1. cnplot = map.contour(x,y,var,dlevs,colors='k')


cbar = map.colorbar(maplot1,location='bottom',pad="10%", label='T avg July oC') cbar.set_label(legtitle, fontsize=20)

cbar.ax.tick_params(labelsize=16)

plt.clabel(cnplot, fmt='%.0f',fontsize=15, inline=1)

plt.title(plottitle, fontsize=24)

  1. plt.show()

plt.savefig(outimage, bbox_inches='tight', dpi=dpi) plt.savefig(outpdf, bbox_inches='tight', dpi=dpi)




OLD SLOW AND CLUMSY CODE

  1. -*- coding: utf-8 -*-

from mpl_toolkits.basemap import Basemap, cm import matplotlib.pyplot as plt from netCDF4 import Dataset as open_ncfile import numpy as np

    1. preprocess with GMT 5.4
  1. gmt grdcut tk7_gauss1.nc -Gwest_europe_tk7.nc -R-10/50/30/60

zvarlabel='z' latvarlabel='lat' lonvarlabel='lon' lona=-10 lonb=50 lata=30 latb=60 latdx=5 londy=5 zeta=-25 zetb=25 deltazc=0.5 deltazd=5 legtitle="oC" plottitle="T July, LGM (CCSM4)" dpi = 100

outimage="out.png"

  1. -- open netcdf file

nc = open_ncfile('west_europe_tk7.nc')

var = nc.variables[zvarlabel][:,:]

lat = nc.variables[latvarlabel][:] lon = nc.variables[lonvarlabel][:]

  1. -- create figure and axes instances

fig = plt.figure(figsize=(1100/dpi, 1100/dpi), dpi=dpi) ax = fig.add_axes([0.1,0.1,0.8,0.9])

map = Basemap(projection='cyl',llcrnrlat=lata,urcrnrlat= latb,\

             resolution='h',  llcrnrlon=lona,urcrnrlon=lonb)

map.drawcoastlines() map.drawrivers()

  1. map.drawstates()
  2. map.drawcountries()

kolorado=('r', 'r', 'r', 'r','r','r','r', 'r', 'r', 'r', 'r','r','r','r' )

map.drawparallels(np.arange(lata, latb,latdx),labels=[1,0,0,0],fontsize=10) map.drawmeridians(np.arange(lona,lonb,londy),labels=[0,0,0,1],fontsize=10)

x, y = map(*np.meshgrid(lon,lat))

clevs = np.arange(zeta,zetb,deltazc) dlevs = np.arange(zeta,zetb,deltazd)

cnplot = map.contourf(x,y,var,clevs,antialiased=True,cmap=plt.cm.jet)

    1. cnplot = map.contour(x,y,var,clevs,cmap=plt.cm.jet)

cbar = map.colorbar(cnplot,location='bottom',pad="10%") cbar.set_label(legtitle)

cnplot = map.contour(x,y,var,dlevs,colors=kolorado,) plt.clabel(cnplot, fmt='%.0f',fontsize=12, inline=1)

plt.title(plottitle)

  1. plt.show()

plt.savefig("out.png", bbox_inches='tight', dpi=dpi) plt.savefig("out.pdf", bbox_inches='tight', dpi=dpi )

bash

  1. gmt grdcut tk7_gauss1.nc -Gwest_europe_tk7.nc -R-10/50/30/60

python2 hevi1.py pdf2svg out.pdf out.svg inkscape -z -e out.png -w 1024 -h 512 out2.svg svgo out.svg

bash gauss

ingrid1="../ccsm/data/cclgmtk7.nc" ingrid2="../ccsm/data/cclgmtk1.nc" ingrid3="../ccsm/data/cclgmbi1.nc"

outgridbase1="tk7_gauss1" outgridbase2="tk1_gauss1" outgridbase3="ta_gauss1"

saga_cmd grid_filter 1 -INPUT $ingrid3 -RESULT $outgridbase3 -SIGMA 6 -RADIUS 6 gdal_translate -of GMT $outgridbase3".sdat" temp.nc

gdal_calc.py -A temp.nc --outfile="temp2.tif" --calc="(A/10)"

gdal_translate -of netCDF temp2.tif $outgridbase3".nc"

exit

saga_cmd grid_filter 1 -INPUT $ingrid1 -RESULT $outgridbase1 -SIGMA 6 -RADIUS 6 gdal_translate -of GMT $outgridbase1".sdat" temp.nc

gdal_calc.py -A temp.nc --outfile="temp2.tif" --calc="(A)"

gdal_translate -of netCDF temp2.tif $outgridbase1".nc"

saga_cmd grid_filter 1 -INPUT $ingrid2 -RESULT $outgridbase2 -SIGMA 6 -RADIUS 6 gdal_translate -of GMT $outgridbase2".sdat" temp.nc

gdal_calc.py -A temp.nc --outfile="temp2.tif" --calc="(A)"

gdal_translate -of netCDF temp2.tif $outgridbase2".nc"

bash obtain data

    1. get LGM climate data geotiff
  1. http://www.worldclim.org/paleo-climate1

mkdir data cd data

wget http://biogeo.ucdavis.edu/data/climate/cmip5/lgm/cclgmtn_2-5m.zip wget http://biogeo.ucdavis.edu/data/climate/cmip5/lgm/cclgmtx_2-5m.zip wget http://biogeo.ucdavis.edu/data/climate/cmip5/lgm/cclgmpr_2-5m.zip wget http://biogeo.ucdavis.edu/data/climate/cmip5/lgm/cclgmbi_2-5m.zip

unzip cclgmtn_2-5m.zip unzip cclgmtx_2-5m.zip unzip cclgmpr_2-5m.zip unzip cclgmbi_2-5m.zip

rm *.zip

cd ..

mkdir plot mkdir teksti

    1. init mapping utilzzz

sudo apt install gdal-bin python-gdal nco cdo ctioga2 libnetcdf libnetcdf-dev -y

    1. sumenna.bash
  1. sudo apt install saga
gcc -o ncblit1 ncblit1.c -lm -lnetcdf
gcc -o ncprobe1 ncprobe1.c -lm -lnetcdf

bahs to prepare data

sorckanta1="cclgmtn" sorckanta2="cclgmtx" sorckanta3="cclgmpr" sorckanta4="cclgmtk" psorckanta1="cclgmbi"

cd data

for i in {1..12..1}

 do
  
    sorcnimi1=$sorckanta1$i.tif
    sorcnimi2=$sorckanta2$i.tif
    sorcnimi3=$sorckanta3$i.tif
    sorcnimi4=$sorckanta4$i.tif
    nesorcnimi1=$sorckanta1$i.nc
    nesorcnimi2=$sorckanta2$i.nc
    nesorcnimi3=$sorckanta3$i.nc
    nesorcnimi4=$sorckanta4$i.nc
   gdal_calc.py -A $sorcnimi1 -B $sorcnimi2 --outfile=$sorcnimi4 --calc="(A+B)/20"
  gdal_translate -ot Float32 -of netCDF $sorcnimi1 $nesorcnimi1
  gdal_translate -ot Float32 -of netCDF $sorcnimi2 $nesorcnimi2
  gdal_translate -ot Float32 -of netCDF $sorcnimi3 $nesorcnimi3
  gdal_translate -ot Float32 -of netCDF $sorcnimi4 $nesorcnimi4
done

for i in {1..15..1}

 do
    psorcnimi1=$psorckanta1$i.tif
   
    pesorcnimi1=$psorckanta1$i.nc
    
    gdal_calc.py -A $psorcnimi1 --outfile=temp.tif --calc="A"
  
    gdal_translate -ot Float32 -of netCDF temp.tif $pesorcnimi1
  
done

cd ..

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current14:45, 1 September 2019Thumbnail for version as of 14:45, 1 September 20191,236 × 1,052 (7.12 MB)Merikanto (talk | contribs)Correction of text label
14:34, 1 September 2019Thumbnail for version as of 14:34, 1 September 20191,236 × 1,052 (7.12 MB)Merikanto (talk | contribs)Faster code
16:11, 6 December 2018Thumbnail for version as of 16:11, 6 December 2018911 × 566 (5.67 MB)Merikanto (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

Metadata