current position:Home>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:48【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 ;
copyright notice
author[It's hard not to write code all day],Please bring the original link to reprint, thank you.
https://en.chowdera.com/2022/175/202206241030564288.html
The sidebar is recommended
- Tencent Youtu, together with Tencent security Tianyu and wechat, jointly launched an infringement protection scheme
- Fbnet/fbnetv2/fbnetv3: Facebook's lightweight network exploration in NAS | lightweight network
- A flaw in R markdown: folders cannot have Chinese
- Getting started with scrapy
- Detailed explanation of the execution order of the expression and loop body in the for loop
- Remote terminal RTU slope monitoring and early warning
- Jupyter notebook service installation and startup
- About Adobe Photoshop adjusting selection
- Kubernetes practical skills: use cert manager to issue free certificates for DNSPod domain names
- In depth analysis, from ordinary clock system to various time service modes
guess what you like
What are the software prototyping tools?
[tke] GPU node NVIDIA Tesla driver reinstallation
A good habit that makes your programming ability soar
Google hacking search engine attack and Prevention
Data stack technology sharing: open source · data stack - extend flinksql to realize the join of flow and dimension tables
Pinduoduo press the user accelerator key
Installing sqlserver extension PDO of PHP under Linux_ sqlsrv
Go basic series | 1 Leading
Node cache vs browser cache
Istio practical skills: implement header based authorization
Random recommended
- [Tencent cloud 618 countdown!] Promotion strategy of the promotion activities
- Simple and flexible permission design?
- Making daily menu applet with micro build low code
- 99% of the students can't write good code because of this problem!
- Istio practical skills: using prism to construct multi version test services
- Kubernetes practical technique: setting kernel parameters for pod
- A scheme for crawlers to collect public opinion data
- Essential key steps in the construction of e-commerce live broadcast source code
- How do websites and we media tap user needs? Deeply expose the secrets behind the keywords!
- From theory to practice, decipher Alibaba's internal MySQL optimization scheme in simple terms
- Continuous testing | key to efficient testing in Devops Era
- It's settled! Bank retail credit risk control just does it!
- Encapsulate the method of converting a picture file object to Base64
- The pod is evicted due to insufficient disk space of tke node
- Post processing - deep camera deformation effects
- Tencent released credit risk control results safely: it has helped banks lend more than 100 billion yuan
- Interesting erasure code
- Five minutes to develop your own code generator
- How to make secruecrt more productive
- About me, a 19 line programmer
- Kubernetes practical skill: entering container netns
- [programming navigation] the practical code summarized by foreign great God, learned in 30 seconds!
- Design and implementation of high performance go log library zap
- Ghost, a synonym for blog system
- Engage in audio and video development? Several things I have to say about SRT live broadcast protocol
- IOMMU (VII) -vfio and mdev
- [highlights] summary of award-winning activities of Tencent cloud documents
- The programmer's graduation project is still bald after a year
- How to solve the problem that MBR does not support partitions over 2T, and lossless transfer to GPT
- Another prize! Tencent Youtu won the leading scientific and technological achievement award of the 2021 digital Expo
- Use txvideoeditor to add watermark and export video card at 99%? No successful failed callback?
- Reset the password, and the automatic login of the website saved by chrome Google browser is lost. What is the underlying reason?
- [log service CLS] Tencent cloud log service CLS accesses CDN
- [live broadcast of celebrities] elastic observability workshop
- Smart Policing: how to use video intelligent analysis technology to help urban policing visual comprehensive supervision and command system
- SMS SMS
- WPF from zero to 1 tutorial details, suitable for novices on the road
- Dingding, Feishu, and enterprise wechat: different business approaches
- [2022 national tournament simulation] BigBen -- determinant, Du Jiao sieve
- How to do research on plant endophytes? Special topic on Microbiology