Editing
Library Reference
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=Java API= ''There are two APIs available for Java. New programs should be written to use the SWIG API. The Mines JTK API is provided here only for reference for those who may still be using it.'' == SWIG API == The SWIG API includes three classes. The methods that each class exposes are as follows: === RSF === <java> public RSF(String[] args); // Constructor, pass the command line arguments public float getFloat(String key, float default); // Gets the command line argument associated with this key. public int getInt(String key, int default); // Gets an int from the command line associated with this key. public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key. public String getString(String key, String default); // Gets a string corresponding to this key. </java> === Input === <java> public Input(String name); // Constructor, pass a filename. "in" defaults to stdin public int getN(int index); // Gets the number of elements in the file for that index. Counting starts at 1. Returns 1 if not found. public float getDelta(int index); // Gets the delta for that index. Returns 0.0 if not found. public float getOrigin(int index); // Gets the origin for that file. Returns 0.0 if not found. public String getLabel(int index); // Gets the label name for the index. Returns "" if not found. public String getUnit(int index); // Gets the unit for the index. Returns "" if not found. public void close(); // Close the file. public void read(float[] array); // Read data from the open RSF file into the given array. Reads the length of the array only. public void read(float[][] array); // The following methods all read data from the RSF file in the given shape of the array. public void read(float[][][] array); public void read(float[][][][] array); public void read(float[][][][][] array); public void read(float[][][][][][] array); public void read(float[][][][][][][] array); public void read(float[][][][][][][][] array); public void read(float[][][][][][][][][] array); </java> === Output === <java> public Output(String name); // Constructor, pass a filename. "out" points to standard out. public void setN(int index, int n); // Gets the number of elements in the file for that index. Counting starts at 1. Returns 1 if not found. public void setDelta(int index, float delta); // Gets the delta for that index. Returns 0.0 if not found. public void setOrigin(int index, float origin); // Gets the origin for that file. Returns 0.0 if not found. public void setLabel(int index, String label); // Gets the label name for the index. Returns "" if not found. public void setUnit(int index, String unit); // Gets the unit for the index. Returns "" if not found. public void close(); // Close the file. public void write(float[] array); // Writes data to the RSF file from the given array. Writes the shape of the array only. public void write(float[][] array); // The following methods all write data using the given shape of the array. public void write(float[][][] array); public void write(float[][][][] array); public void write(float[][][][][] array); public void write(float[][][][][][] array); public void write(float[][][][][][][] array); public void write(float[][][][][][][][] array); public void write(float[][][][][][][][][] array); </java> Additional notes: Java does not support complex numbers by default. To use complex numbers, you must convert complex valued RSF files to floating point numbers using sfdd . == MINES JTK API == ''' THIS API IS DEPRECATED. PLEASE DEVELOP YOUR PROGRAMS TO BE COMPATIBLE WITH THE SWIG API.''' The following methods are exposed directly at this time: ==Par Class== <java> public float getFloat(String key, float default); // Gets the command line argument associated with this key. public int getInt(String key, int default); // Gets an int from the command line associated with this key. public boolean getBool(String key, boolean default); // Gets a boolean from the command line associated with this key. public String getString(String key, String default); // Gets a string corresponding to this key. </java> ==Header Class== <java> public void setN(int dim, int n); // Used to set the number of elements in a dimension. For dimension 1, use an index value of 1. public int getN(int dim); public void setDelta(int dim, float delta); // Used to set the delta for a dimension. For dimension 1, use an index value of 1, not 0. public float getDelta(int dim); public void setOrigin(int dim, float origin); // Used to set the origin for a dimension. public float getOrigin(int dim); public void setLabel(int dim, String label); // Sets the label for a dimension. public String getLabel(int dim); public void setUnit(int dim, String unit); // Sets the unit for a dimension. public String getUnit(int dim); public void setFormat(String format); // Sets the output format information, has no effect on how Java treats the data. public String getFormat(); public void setPath(String path); /* Sets the location of the binary file that corresponds to this header file. Not used for writing information to an RSF file. */ public String getPath(); public void setName(String name); /* Change the file name that this header corresponds to. When writing this info to an RSF file, the API automatically will determine the binary file that goes along with this filename. */ public String getName(); public String toString(); // Can be used to print out information about the header file. </java> ==Writer Class== When writing out RSF files, the header file is output in the same directory as the java program was executed. The binary file is placed according to the DATAPATH environment variable. <tt>saveName</tt> is the filename that you want to save your header to. Writing to standard out is not supported. All files must be saved via a name. <java> public static void writeRSF(RSFHeader header, float[] data, String saveName); // Writes a 1D array to an RSF Header and binary file public static void writeRSF(RSFHeader header, float[][] data, String saveName); // Writes a 2D array to an RSF header and binary file. public static void writeRSF(RSFHeader header, float[][][] data, String saveName); // Writes a 3D array to an RSF header and binary file. </java> ==Reader Class== <java> public static Header readHeader(String headerFileName); // Used to parse the RSF Header file for information. public static float[] readBinary(RSFHeader header); // Reads the RSF binary data file into a single array. public static float[][] readBinary2D(RSFHeader header); // Reads the RSF binary data file into a 2D array. public static float[][][] readBinary3D(RSFHeader header); // Reads the RSF binary data file into a 3D array. </java>
Summary:
Please note that all contributions to Madagascar are considered to be released under the GNU Free Documentation License 1.3 or later (see
My wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
English
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Getting Madagascar
download
Installation
GitHub repository
SEGTeX
Introduction
Package overview
Tutorial
Hands-on tour
Reproducible documents
Hall of Fame
User Documentation
List of programs
Common programs
Popular programs
The RSF file format
Reproducibility with SCons
Developer documentation
Adding programs
Contributing programs
API demo: clipping data
API demo: explicit finite differences
Community
Conferences
User mailing list
Developer mailing list
GitHub organization
LinkedIn group
Development blog
Twitter
Slack
Tools
What links here
Related changes
Special pages
Page information