In using GrADS, you likely want to access metadata from the file, for example: The calendar date of your current time step, or your current latitude range. This post will serve as a reference table that includes code segments for many common metadata queries (most of which can be used to add more data to your plot). In addition, it will include code segments that use

*'set gxout stat'*to query basis statistics about your data. The code within the table can just be copy pasted into your scripts, you will then just have to follow the naming convention that I came up with.

The focus will be on the following queries:

*'q dims'**'q file'**'q gxinfo'**'q xinfo'**'q time'**'q**ctlinfo'*

Result | Code |

Get time step of file (dt) | 'q ctlinfo' tdef=sublin(result,7);dt=subwrd(tdef,5) |

Get longitude resolution of file (dlon) | 'q ctlinfo' dlon=sublin(result,4);dlon=subwrd(dlon,5) |

Get latitude resolution of file (dlat) | 'q ctlinfo' dlat=sublin(result,5);dlat=subwrd(dlat,5) |

Get Number of time steps in file | 'q file' t=sublin(result,5);t=subwrd(t,12) |

Get Number of x-points in file | 'q file' xpts=sublin(result,5);xpts=subwrd(xpts,3) |

Get Number of y-points in file | 'q file' ypts=sublin(result,5);ypts=subwrd(ypts,6) |

Get Number of z-points in file | 'q file' zpts=sublin(result,5);zpts=subwrd(zpts,9) |

Get current longitude range (if longitude is varying) | 'q dims' lons=sublin(result,2) lon1=subwrd(lons,6) lon2=subwrd(lons,8) |

Get current latitude range (if latitude is varying) | 'q dims' lats=sublin(result,3) lat1=subwrd(lats,6) lat2=subwrd(lats,8) |

Get page coordinates of a specific lat/lon pair | 'q w2xy 'lon' 'lat xpos=subwrd(result,3) ypos=subwrd(result,6) |

Get boundaries of plot in page units | 'q gxinfo' xlims=sublin(result,3);ylims=sublin(result,4) xmin=subwrd(xlims,4);xmax=subwrd(xlims,6) ymin=subwrd(ylims,4);ymax=subwrd(ylims,6) |

Get current time range (Including day of the week) | 'q time' time1=subwrd(result,3);weekday1=subwrd(result,6) time2=subwrd(result,5);weekday2=subwrd(result,7) |

Get graphics window size in pixels | 'q xinfo' xpx=sublin(result,4);xpx=subwrd(xpx,4) ypx=sublin(result,5);ypx=subwrd(ypx,4) |

Below is a table showing how to use the

*'set gxout stat'*option to get some basic statistical properties of your variables. Before any of these are used, you need to first to change your graphics out option to stat:

*'set gxout stat'*and then display your variable. Example below:

*'set gxout stat'*

*'d rh2m'*

This will print out a list of

*data onto to GrADS text window, then the following table will be useful for pulling out various statistics*

Stat | Code |

N (data points) | N=sublin(result,11);N=subwrd(N,5) |

Mean | mean=sublin(result,12);mean=subwrd(mean,2) |

Standard Deviation | std=sublin(result,13);std=subwrd(std,2) |

Max | max=sublin(result,9);max=subwrd(max,5) |

Min | min=sublin(result,9);min=subwrd(min,4) |

Any way to test significance in GrADS, like t-test. Help much appreciated

ReplyDelete