File:Ccsm4 lgm usa temperature annual 1.svg

Original file(SVG file, nominally 1,056 × 816 pixels, file size: 946 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary edit

Description
English: Annual temperature , USA , Last Glacial Maximum.
Date
Source Own work
Author Merikanto

Source of data is WorldClim 1.4 LGM data

http://www.worldclim.org/paleo-climate1 archive copy at the Wayback Machine

Last Glacial Maximum CCSM4 downscaled to 2.5 min resolution with ANUSPLIN

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

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.

Visualization with NASA Panoply, Output is converted with pdf2svg and optimized with svgo.

Data is processed with GDAL and CDO for visuialization

Processing scripts un debian/ubuntu/mint or such Linux:

    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

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 ..

Not necessary with Panoply!

ay="40" ax="160" by="80" bx="220"

koords=$ay":"$ax":"$by":"$bx

inufold="./data/" outtafold="./data/"

simulat="cclgm"

sorckanta1=$simulat"tn" sorckanta2=$simulat"tx" sorckanta3=$simulat"pr" sorckanta4=$simulat"tk" psorckanta1=$simulat"bi"

outtabase="beringia_"

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

 do
  
 iname1=$inufold$sorckanta4$i".nc"
 iname2=$inufold$sorckanta3$i".nc"
 oname1=$outtafold$outtabase$sorckanta4$i".nc"
 oname2=$outtafold$outtabase$sorckanta3$i".nc"
 echo $iname1" "$oname1
  1. echo $koords
 ./ncblit1 -i $iname1 -o temp1.nc -k $koords 
 ./ncblit1 -i $iname2 -o temp2.nc -k $koords 
 
 cdo setmissval,-32767 temp1.nc $oname1
 cdo setmissval,-32767 temp2.nc $oname2
done

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

 do
  
 iname1=$inufold$psorckanta1$i".nc"
 oname1=$outtafold$outtabase$psorckanta1$i".nc"

 echo $iname1
 echo $oname1
 ./ncblit1 -i $iname1 -o temp.nc -k $koords 
  cdo setmissval,-32767 temp.nc $oname1
done

And cprogs

ncblit

// ncblit1.c // takes subset window of single input netcdf file // and saves it output netcdf file

// netcdf4 .nc version 4

// ubuntu, mint ... // sudo apt install build-essential //sudo apt-get install libnetcdf-dev

// gcc -o ncblit1 ncblit1.c -lm -lnetcdf // 2d grid 96x48 grid lon,lat,TS

  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <string.h>
  4. include <math.h>
  5. include <netcdf.h>
  1. define NDIMS 2

//#define NLAT 48 //#define NLON 96

  1. define NLAT 3600
  2. define NLON 8640
  1. define UNITS "units"
  2. define DEGREES_EAST "degrees_east"
  3. define DEGREES_NORTH "degrees_north"
  1. define ERR(e) {printf("Error: %s\n", nc_strerror(e)); return 2;}

char iname[1024]="in.nc"; char oname[1024]="out.nc";

char lat_name1[1024]= "lat"; char lon_name1[1024]= "lon"; char z_name1[1024]= "Band1"; char z_units1[] = "units";

char lat_name2[1024]= "lat"; char lon_name2[1024]= "lon"; char z_name2[1024]= "Band1"; char z_units2[] = "units";

int nlat1=NLAT; int nlon1=NLON; int nlat2=NLAT; int nlon2=NLON;

double anax=0.0; double anay=0.0; double anlx=45.0; double anly=45.0;

char bufu[1024];

//float *lats2=NULL;

float *lats2=NULL; float *lats1=NULL; float *lons1=NULL; float *lons2=NULL;

float *z1=NULL; float *z2=NULL;

int ncwrite1(char *outfiili) {

  int ncid, lon_dimid, lat_dimid, pres_varid, z_varid;
  int lat_varid, lon_varid;
  int dimids[NDIMS];
  int retval;
  if ((retval = nc_create(outfiili, NC_CLOBBER, &ncid)))
     ERR(retval);
  if ((retval = nc_def_dim(ncid, lat_name2, nlat2, &lat_dimid)))
     ERR(retval);
  if ((retval = nc_def_dim(ncid, lon_name2, nlon2, &lon_dimid)))
     ERR(retval);
  if ((retval = nc_def_var(ncid, lat_name2, NC_FLOAT, 1, &lat_dimid,

&lat_varid)))

     ERR(retval);
  if ((retval = nc_def_var(ncid, lon_name2, NC_FLOAT, 1, &lon_dimid,

&lon_varid)))

     ERR(retval);
  if ((retval = nc_put_att_text(ncid, lat_varid, UNITS,

strlen(DEGREES_NORTH), DEGREES_NORTH)))

     ERR(retval);
  if ((retval = nc_put_att_text(ncid, lon_varid, UNITS,

strlen(DEGREES_EAST), DEGREES_EAST)))

     ERR(retval);
  dimids[0] = lat_dimid;
  dimids[1] = lon_dimid;
  if ((retval = nc_def_var(ncid, z_name2, NC_FLOAT, NDIMS,

dimids, &z_varid)))

     ERR(retval);
  if ((retval = nc_put_att_text(ncid, z_varid, UNITS,

strlen(z_units2), z_units2)))

     ERR(retval);
  if ((retval = nc_enddef(ncid)))
     ERR(retval);

// printf("\n nlat2 %i %f %f",nlat2, lats2[0], lats2[1]); // printf("\n nlon2 %i %f %f",nlon2, lons2[0],lons2[1] );

//   printf("\n z2 %f %f ", z2[0],z2[1]);
       
  if ((retval = nc_put_var_float(ncid, lat_varid, &lats2[0])))
     ERR(retval);
  if ((retval = nc_put_var_float(ncid, lon_varid, &lons2[0])))
     ERR(retval);
  if ((retval = nc_put_var_float(ncid, z_varid, &z2[0])))
     ERR(retval);
  if ((retval = nc_close(ncid)))
     ERR(retval);
  return 0;

}

int ncread3(char *infiili) {

  int ncid, pres_varid, temp_varid;
  int lat_varid, lon_varid;
  int ndims_in, nvars_in, ngatts_in, unlimdimid_in;
  int retval;
  if ((retval = nc_open(infiili, NC_NOWRITE, &ncid)))
     {
printf("\n %s :", infiili);
     ERR(retval);
      }
  if ((retval = nc_inq_varid(ncid, lat_name1, &lat_varid)))
     ERR(retval);
  if ((retval = nc_inq_varid(ncid, lon_name1, &lon_varid)))
     ERR(retval);
  if ((retval = nc_get_var_float(ncid, lat_varid, lats1)))
     ERR(retval);
  if ((retval = nc_get_var_float(ncid, lon_varid, lons1)))
     ERR(retval);
  if ((retval = nc_inq_varid(ncid, z_name1, &temp_varid)))
     ERR(retval);
  if ((retval = nc_get_var_float(ncid, temp_varid, z1)))
     ERR(retval);
  if ((retval = nc_close(ncid)))
     ERR(retval);
  return 0;

}

int initdata1(int nx, int ny) { //freedata();

z1=malloc(nx*ny*sizeof(float)); if(z1) { memset(z1,0, nx*ny*sizeof(float) ) ; }

lons1=malloc(nlon1*sizeof(float)); if(lons1) { memset(lons1,0, nlon1*sizeof(float) ) ; }

lats1=malloc( nlat1*sizeof(float) ); if(lats1) { memset( lats1,0, nlat1*sizeof(float) ) ; } return(0); }

int initdata2(int nx, int ny) { //freedata();

z2=malloc(nx*ny*sizeof(float)); if(z2) { memset(z2,0, nx*ny*sizeof(float) ) ; }

lons2=malloc(nlon2*sizeof(float)); if(lons2) { memset(lons2,0, nlon2*sizeof(float) ) ; }

lats2=malloc( nlat2*sizeof(float) ); if(lats2) { memset( lats2,0, nlat2*sizeof(float) ) ; }

return(0); }

void freedata() { if(z1) { free(z1); z1=NULL;

    }

if(lons1) { free(lons1); lons1=NULL;

    }
    	 if(lats1)

{ free(lats1); lats1=NULL;

    }

if(z2) { free(z2); z2=NULL;

    }

if(lons2) { free(lons2); lons2=NULL;

    }
    /*
    	 if(lats2)

{ free(lats2); lats2=NULL;

    }
  • /

}

int copykuva(void) {

  int lat, lon;
  double lata, longa=0.0;
  double dylat, dxlon=0.0;

/*

  lata=-90.0;
  longa=-180.0;
  dylat=180.0/nlat1;
  dxlon=360.0/nlon1;
  for (lat = 0; lat < nlat; lat++)
     lats[lat] = lata + dylat*lat;
  for (lon = 0; lon < nlon; lon++)
     lons[lon] = longa + dxlon*lon;
  */
    for (lat = 0; lat < nlat1; lat++)
    {

lats2[lat]=lats1[lat]; }

    for (lon = 0; lon < nlon1; lon++)
    {

lons2[lon]=lons1[lon]; }

  for (lat = 0; lat < nlat1; lat++)
     for (lon = 0; lon < nlon1; lon++)
     {
        z2[lat*nlon1+lon]= z1[lat*nlon1+lon];
     }

}

int nearest_lon(double longa) { int indexi=-1; int lon=0;

for (lon = 0; lon < nlon1; lon++) { indexi=lon; if(longa>=lons1[lon]) { if(longa<=lons1[lon+1]) { return(indexi);

} }

      }

return(-1); }

int nearest_lat(double lata) { int indexi=-1; int lat=0;

for (lat = 0; lat < nlat1; lat++) { if(lata>=lats1[lat]) {

if(lata<=lats1[lat+1])

 					{

indexi=lat; return(indexi);

} }

      }

return(-1); }

int printlonlat(void) { int lat, lon=0; /* for (lat = 0; lat < nlat2; lat++)

    {   
        printf(" %f ", lats2[lat]);
    }
 */  
  for (lon = 0; lon < nlon2; lon++)
    {   
        printf(" %f ", lons2[lon]);
    }

/*

	 for (lat = 0; lat < nlat2; lat++)
    {   
        printf("\n");
      for (lon = 0; lon < nlon2; lon++)
      {   
        printf("%f ", z2[lat*nlat2+lon]);
      }
    
   }
 */       
    return(0);  

}

int latideksi(double neula) {

 int n=0, deksi=0;
 deksi=-1;
 
 for(n=0;n<nlat1; n++)
   {
     if (lats1[n]>=neula) 
      {
       deksi=n;
       break;
     }
   }
  return deksi;

}

int lonideksi(double neula) {

 int n=0, deksi=0;
 deksi=-1;
 
 for(n=0;n<nlon1; n++)
   {
     if (lons1[n]>=neula) 
      {
       deksi=n;
       break;
     }
   }
  return deksi;

}

int nc_blit(double lata, double lona, double latb, double lonb) {

   int srcax, srcay, srcbx, srcby=0;
   int srcmx, srcmy=0;
   int srccx, srccy;
   int srcnx, srcny=0;
 //  int ofx,ofy=0;
   int lat, lon=0;
   double dstdlat, dstdlon;
   int liputus=0;
   double lonc=0.0;
   long dexal=0;

// worldclim rect // -180 ... 180, +90 - -60 // ofx=0;

//   ofy=0;
   liputus=0;
  

// if(lona<180.0) // {

   if(lonb>=180.0) 
    {
     liputus=1;
     lonc=360-lonb;
     lonb=lons1[lonideksi(179.97)-1];
//     lonb=lons1[nlon1];
 //    printf("\n LONA LONB %f %f %f\n",lona,lonb, lonc);  
   }

// }

// exit(-1);

  // jn test break;
   srcax=lonideksi(lona);
   srcay=latideksi(lata);
   srcbx=lonideksi(lonb);
   srcby=latideksi(latb);

   srccx=lonideksi(lonc);
   srccy=latideksi(latb);

   srcmx=abs(srcbx-srcax);
   srcmy=abs(srcby-srcay);

   srcnx=abs(srccx-srcbx);
   srcny=abs(srccy-srcby);
 
   dstdlat=fabs(latb-lata)/srcmy;
   dstdlon=fabs(lonb-lona)/srcmx;

// printf("\n dlat dlon %f %f \n ",dstdlat, dstdlon);

  nlon2=srcmx;
 if(liputus==1)
 {   
    nlon2=srcmx+srcnx;
 }
 
   nlat2=srcmy;

// printf("\n SRC %i %i %i",srcax, srcbx, srccx);

// printf("\n MNX %i %i %i",srcmx, srcnx, nlon2);
   if(z2) free(z2);

z2=malloc(nlon2*nlat2*sizeof(float)); if(z2) { memset(z2,0, nlon2*nlat2*sizeof(float) ) ; }

   if(lons2) free(lons2);

lons2=malloc(nlon2*sizeof(float)); if(lons2) { memset(lons2,0, nlon2*sizeof(float) ) ; }

   if(lats2) free(lats2);

lats2=malloc(nlat2*sizeof(float)); if(lats2) { memset(lats2,0, nlat2*sizeof(float) ) ; }

/*

  for (lat = 0; lat < nlat2; lat++)
     lats2[lat] = lata + dstdlat*lat;
  for (lon = 0; lon < nlon2; lon++)
     lons2[lon] = lona + dstdlon*lon;
  • /
    for (lat = 0; lat < nlat2; lat++)
    {

lats2[lat]=lats1[srcay+lat]; }

/*

    for (lon = 0; lon < nlon2; lon++)
    {

lons2[lon]=lons1[srcax+lon]; }

  • /
    for (lon = 0; lon < srcmx; lon++)
    {

lons2[lon]=lons1[srcax+lon]; }

  if(liputus==1)
   {
        for (lon = 0; lon < srcnx; lon++)
    {

lons2[lon+srcmx]=lons1[lon]; }

    }
  for (lat = 0; lat < nlat2; lat++)
  {
     for (lon = 0; lon < nlon2; lon++)
     {
        dexal=(srcay+lat)*nlon1+srcax+lon;
        z2[lat*nlon2+lon]= z1[dexal];
     }
  }

/*

if(liputus==1)

 {
  for (lat = 0; lat < nlat2; lat++)
  {
     for (lon = 0; lon < nlon2; lon++)
     {
        dexal=(srcay+lat)*nlon1+srcbx+lon;
        z2[lat*nlon2+lon]= z1[dexal];
     }
  }
  }
  • /

}

void mutatekoords(void) {

// process koords for netcdf data cutter
// c
// anlx > 180 or
 if(anlx<0)
  {
   if(anax>0)
    {
       anlx=360+anlx;
    }
 }

}

int processkoords(char* instringi) {

 char *p, *q=NULL;
 int lena, n, m=0;

/* double anax=0.0; double anay=0.0; double anlx=45.0; double anly=45.0;

  • /
 memset(bufu,0,1024);
 strcpy(bufu,instringi);
 p=bufu;
 q=bufu;
 strcat(bufu, ":");
 lena=strlen(bufu);

// printf("\n %s", bufu);

for(n=0;n<4;n++)
 {
    q=strchr(p,':');
    *q=0;
   if (n==0) anay=atof(p);
    if (n==1) anax=atof(p);
    if (n==2) anly=atof(p);
    if (n==3) anlx=atof(p);

    p=q+1;
  }
//    printf("\n KOORDS %f %f %f %f",anay,anax,anly, anlx);
return(0);

}

int init_data0(void) {

    anax=0.0;
    anay=0.0;
    anlx=45.0;
    anly=45.0;

nlon1=8640; nlat1=3600; nlon2=8640; nlat2=3600;

    memset(z_name1,0,1024);
    strcpy(z_name1,"Band1");
  return(0);

}

int init_data1(void) {

initdata1(nlon1, nlat1);

nlon2=nlon1; nlat2=nlat1; initdata2(nlon2,nlat2);

  return(0);

}

void avuste(void) {

 printf("\n ncblit1  creates areea .nc file (spatial subset or winndow ) of single .nc file");
 
 printf("\n Inputfile is netcdf data file, format 2D lon, lat, Band1 Float32");
 printf("\n coordinates form of file is (lon, lat) decimal degrees -180.0 .. 180.0, -90.0 ... 90.0 ");
   
 printf("\n usage tex. ncblit1 -i in.nc -o out.nc -k 10.00:20.00:80.00:120.00");
 printf("\n-i inputfile (.nc netcdf Float32 file)");
 printf("\n-o outputfile (.nc netcdf Float32 file) "); 
 printf("\n-b band name, default is Band1 "); 
 printf("\n-wi nc file width, default is 8640 ");
 printf("\n-he nc file width, default is 3600 ");
 printf("\n -h ( or --help, this help screen");  

}

int parsi_argut(int argc, char **argv) {

  int n=0;

  if(argc>1)
    {
      for(n=0;n<argc;n++)
       {

if( !strcmp(argv[n],"-h") ) { avuste(); exit(0); }

            if( !strcmp(argv[n],"--help") )

{ avuste(); exit(0); }

           if( !strcmp(argv[n],"-i") )
           {
               if(argv[n+1])
                {
                strcpy(iname, argv[n+1]);
                }
           }
           if( !strcmp(argv[n],"-o") )
           {
               if(argv[n+1])
                {
                strcpy(oname, argv[n+1]);
                }
           }
                if( !strcmp(argv[n],"-b") )
           {
               if(argv[n+1])
                {
                strcpy(z_name1, argv[n+1]);
                strcpy(z_name2, argv[n+1]);  

}

           }

               if( !strcmp(argv[n],"-wi") )
           {
               if(argv[n+1])
                {
               nlon1=atof(argv[n+1]);

}

           }
               if( !strcmp(argv[n],"-he") )
           {
               if(argv[n+1])
                {
               nlat1=atof(argv[n+1]);

}

           }
               if( !strcmp(argv[n],"-k") )
           {
               if(argv[n+1])
                {
               processkoords(argv[n+1]);

}

           }
       }
    }
return(0);

}

int main(int argc, char **argv) {

   init_data0();
 
//  processkoords("1.0:1.0:45.0:60.0");

// processkoords("40:160.0:80.0:-160");

 //    processkoords("40:-140.0:80.0:-100");

// mutatekoords();

   parsi_argut(argc, argv);
   mutatekoords();
   init_data1();
 //   printf("\n ncread ...");
   ncread3(iname);

// printf("\n ncread ");

   nc_blit(anay,anax,anly,anlx);

// printf("\n %s", oname);

   ncwrite1(oname);

freedata();

    printf("\n");
    return(0);

}

for filei in *.pdf do

 #echo $filee
 filename="${filei%.*}"
 fileo=$filename".svg"
 echo $filei, $fileo
 pdf2svg $filei $fileo
 svgo $fileo

done

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
current19:13, 3 December 2018Thumbnail for version as of 19:13, 3 December 20181,056 × 816 (946 KB)Merikanto (talk | contribs)User created page with UploadWizard

The following page uses this file:

Metadata