当前位置:网站首页>Parse NC format file and GRB format file dependent package edu ucar. API learning of netcdfall
Parse NC format file and GRB format file dependent package edu ucar. API learning of netcdfall
2022-06-24 12:38:00 【It's hard not to write code all day】
Catalog
0 Purpose
There are few online learning materials that depend on this package , So tidy this bag , Some things we can use in our work api To study
https://www.unidata.ucar.edu/
https://www.unidata.ucar.edu/software/netcdf/examples/programs/
https://docs.unidata.ucar.edu/netcdf-java/5.1/userguide/common_data_model_overview.html#data-access-layer-object-model
https://docs.unidata.ucar.edu/netcdf-java/5.1/userguide/using_netcdf_java_artifacts.html
python
https://unidata.github.io/MetPy/latest/examples
1 Why learn this dependency
Now there are many formats of data , For example, meteorological data , Generally used nc Format file for storage , We got this file , In our project code , To parse , This nc The format file is binary stream , So you need to use professional tools to parse , This dependency is to help us resolve in our project nc Format
2 Common data model
Common Data Model It has three layers , They build on each other to add richer semantics in turn :
1 Data access layer , Also known as the syntactic layer , Handle data reading and writing .
2 The coordinate system layer identifies the coordinates of the data array . Coordinates are a complete representation of scientific data
General concept ; We have also established a special geographic reference coordinate system ,
This is very important to the earth science community .
3 Scientific Feature Types Layers identify specific types of data ,
For example, grid 、 Radial and point data , Add special methods for each type of data .
3 Data access layer object model

3.1 Dataset
Dataset = Data sets
Data sets can be netCDF、HDF5、GRIB Wait for the documents 、OPeNDAP Data sets 、 A collection of files can be accessed through netCDF API Any other content accessed . We sometimes use the term CDM Data sets to represent any of these possibilities , And emphasize that the dataset does not have to be netCDF File format .
The type of dataset we often use is :
nc Format GRB Format ,DAT Format
3.2 Group
Group = Group
Group is an attribute 、 dimension 、EnumTypedef、 Containers for variables and nested groups .Dataset Medium Groups Form a hierarchical tree , Just like a directory on a disk .Dataset There is always at least one Group, That is root Group, Its name is an empty string .
3.3 Variable
Variable = Variable
Variables are containers of data . It has a data type 、 A set of dimensions that define the shape of its array , And an optional set of attributes . Any shared dimensions it uses must be in the same group or parent group .

3.4 Dimension
Dimensions are used to define the array shape of variables . It can be shared among variables , This provides a simple and powerful way to correlate variables . When sharing dimensions , It has a unique name within the Group . If there is no limit , The length of the dimension may increase . If it is variableLength, The actual length depends on the data , Only by reading the data can we find .variableLength Dimension Cannot be shared or unrestricted .
3.5 Attribute
Properties have names and values , And associate any metadata with variables or groups . The value is a scalar or one-dimensional array of strings or numbers , So the possible data types are (String、byte、short、int、long、float、double). Integer types (byte、short、int、long) It can be signed or unsigned .
3.6 structure
A structure is a variable that contains other variables , Be similar to C Structure in or in a relational database That's ok . Usually , The data in the structure is physically tightly stored on disk , Therefore, all the data in the structure can be retrieved efficiently at the same time . The variables contained in the structure are member variables , Can only be read in the context of its containing structure .
3.7 Sequence
A sequence is a one-dimensional structure , Its length is unknown before you actually read the data . To access data in a sequence , You can only traverse the sequence , Get data from one structure instance at a time .
3.8 EnumTypedef
EnumTypedef Is an enumeration of strings , from enum Type variables use .
3.9 Array
The array contains the actual data after reading variables from disk or network . You can call read() Or its variant to get an array from a variable . The array is rectangular ( Such as Fortran Array ). Every DataType There's a special Array type .
4 Coordinate system object model

4.1 Variable
** A variable can have zero or more coordinate systems , It contains one or more axes .** If CoordinateAxis The dimension set of is a subset of the dimension set of variables , be CoordinateAxis Can only be variable CoordinateSystem Part of . This ensures that each data point in the variable is for CoordinateSystem Each of the CoordinateAxis Have a corresponding coordinate value .
5 api Study
5.1 open nc file open()
String filename = "E:\\ Grid point \\nc\\66.nc";
NetcdfFile ncfile = null;
try {
ncfile = NetcdfFile.open(filename);
// Console output
System.out.println(ncfile);
} catch (IOException ioe) {
System.out.println("trying to open " + filename+ioe);
} finally {
if (null != ncfile) try {
ncfile.close();
} catch (IOException ioe) {
System.out.println("trying to open " + filename+ioe);
}
}
5.2 findVariable()
According to the specific variable name , Get the specific attributes in the current variable
private static void process(NetcdfFile ncfile){
String varName = "hyai";
Variable v = ncfile.findVariable(varName);
if (null == v) return;
try {
System.out.println(v);
} finally {
}
}

5.3
6 Import dependence
This dependency is added to our project , It is equivalent to adding this parsing nc Documentation software
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>netcdfAll</artifactId>
<version>5.1.0</version>
</dependency>
7 open nc file
We have a nc file 
It means according to the code , Read the contents of this binary file , Let's take a look at what the code reads . Output the read thing to the console , And read TXT file ,
String filename = "E:\\ Grid point \\nc\\66.nc";
NetcdfFile ncfile = null;
try {
ncfile = NetcdfFile.open(filename);
// Console output
System.out.println(ncfile);
} catch (IOException ioe) {
System.out.println("trying to open " + filename+ioe);
} finally {
if (null != ncfile) try {
ncfile.close();
} catch (IOException ioe) {
System.out.println("trying to open " + filename+ioe);
}
}
The output is

You can find , The output is to use panoply Software open nc file ;
边栏推荐
- Tencent released credit risk control results safely: it has helped banks lend more than 100 billion yuan
- 99% of the students can't write good code because of this problem!
- [redisson] analysis of semaphore lock source code
- Coinbase will launch the first encrypted derivative product for retail traders
- The latest hot spot: the use of copper death related genes for tumor prognosis typing!
- LS-DYNA beginner's experience
- How to check the situation that the national standard platform easygbs equipment video cannot be accessed by grabbing packets?
- RTMP streaming platform easydss video on demand interface search bar development label fuzzy query process introduction
- How can I open an account with new bonds? Is it safe
- 炒伦敦金短线稳定赚钱技巧?在哪里炒伦敦金安全靠谱?
猜你喜欢

Opencv learning notes - regions of interest (ROI) and image blending

一纸英雄帖,激起千层浪,横跨10国,一线大厂都派人来了!-GWEI 2022-新加坡

QT -- the qtabwidget supports dragging tabbar items
[mysql_16] variables, process control and cursors

文本转语音功能上线,可以体验专业播音员的服务,诚邀试用

使用开源工具 k8tz 优雅设置 Kubernetes Pod 时区

一文讲透植物内生菌研究怎么做 | 微生物专题

钉钉、飞书、企业微信:迥异的商业门道

Opencv learning notes - Discrete Fourier transform

Group planning - General Review
随机推荐
文本转语音功能上线,可以体验专业播音员的服务,诚邀试用
Popular science of data annotation: ten common image annotation methods
11+ article - machine learning builds Protics framework - deeply reveals the impact of tumor infiltrating immune cells in different molecular subtypes on prognosis
How to solve the problem that MBR does not support partitions over 2T, and lossless transfer to GPT
【数据库】期末复习(计科版)
[redisson] analysis of semaphore lock source code
Programmer: after 5 years in a company with comfortable environment, do you want to continue to cook frogs in warm water or change jobs?
Use txvideoeditor to add watermark and export video card at 99%? No successful failed callback?
I'm in Shenzhen. Where can I open an account? Is it safe to open an account online now?
How to develop mRNA vaccine? 27+ pancreatic cancer antigen and immune subtype analysis to tell you the answer!
IOMMU (VII) -vfio and mdev
Cloud native database: the outlet of the database, you can also take off
Jenkins pipeline syntax
Easynvr user login is modified to share the modification process of ip+ user name restriction
99% of the students can't write good code because of this problem!
Use the object selection tool to quickly create a selection in Adobe Photoshop
A "full cloud" journey of a quasi financial system
Listed JD Logistics: breaking through again
Hardware enterprise website ranking, 8 commonly used processes
JS和TS中常用特殊字符