Welcome to the L3 Harris Geospatial documentation center. Here you will find reference guides and help documents.
﻿

### CDF_VARCREATE

CDF_VARCREATE

The CDF_VARCREATE function creates a new variable in a Common Data Format file.

In CDF, variable is a generic name for an object that represents data. Data can be scalar (0-dimensional) or multi-dimensional (up to 10-dimensional). Data does not have any associated scientific context; it could represent an independent variable, a dependent variable, a time and date value, an image, the name of an XML file, etc. You can describe a variable’s relationship to other variables via CDF’s attributes.

CDF supports two types of variables: zVariables and rVariables. Different zVariables in a CDF data set can have different numbers of dimensions and different dimension sizes. All rVariables in a CDF data set must have the same number of dimensions and the same dimension sizes; this is much less efficient than the zVariable storage mechanism. (rVariables were included in the original version of CDF, and zVariables were added in a later version to address the rVariables’ inefficient use of disk space.)

If you are working with a data set created using an early version of CDF, you may need to use rVariables. If you are creating a new CDF data set, use zVariables.

## Examples

In this example, we create a variable, setting the data type from a string variable, which could have been returned by the DATATYPE keyword to a CDF_VARINQ call:

`; create a file in IDL’s current directory`
`id = CDF_CREATE('temp.cdf')`
` `
`VARTYPE = 'CDF_FLOAT'`
` `
`; Use the _EXTRA keyword and the CREATE_STRUCT function to `
`; make the appropriate keyword.`
` `
`VarId = CDF_VARCREATE(Id, 'Pressure', [1,1], \$`
`   NUMELEM=2, _EXTRA=CREATE_STRUCT(VARTYPE,1))`
`VarId1 = CDF_VARCREATE(id, "Zvar", /CDF_DOUBLE, /ZVARIABLE)`
`VarId2 = CDF_VARCREATE(id, "Zvar", [1,1,1], \$`
`   /CDF_INT4, DIM=[10,20,30])`
`CDF_CLOSE, id ; Close the CDF file.`

## Syntax

Result = CDF_VARCREATE(Id, Name [, DimVary] [, /VariableType] [, ALLOCATERECS=records] [, DIMENSIONS=array] [, NUMELEM=characters] [, /REC_NOVARY | , /REC_VARY] [, /ZVARIABLE] )

## Return Value

Returns the variable of the type specified by the chosen keyword.

## Arguments

### Id

The CDF ID, returned from a previous call to CDF_OPEN or CDF_CREATE.

### Name

A string containing the name of the variable to be created.

### DimVary

A one-dimensional array containing one element per CDF dimension. If the element is non-zero or the string ‘VARY’, the variable will have variance in that dimension. If the element is zero or the string ‘NOVARY’ then the variable will have no variance with that dimension. If the variable is zero-dimensional, this argument may be omitted.

## Keywords

### VariableType

You must specify the type variable being created. This is done by setting one of the following keywords:

### CDF_DOUBLE

(same as CDF_REAL8)

(see note below)

### CDF_FLOAT

(same as CDF_REAL4)

### CDF_TIME_TT2000

If no type is specified, CDF_FLOAT is assumed.

Note: The keyword associated with the CDF_EPOCH16 variable type is CDF_LONG_EPOCH. The keyword name differs from the variable type name to avoid a keyword-name conflict with the CDF_EPOCH keyword. All other references to the CDF_EPOCH16 variable type use the variable type name.

Note: CDF_TIME_TT2000 is the nano-seconds since J2000 with leap seconds. It uses the same IDL data type as CDF_INT8, IDL_TYP_LONG64. If you use an attribute entry of CDF_TIME_TT2000, be sure to set the /CDF_EPOCH keyword for the CDF_ATTPUT call.

### ALLOCATERECS

Set this keyword equal to the desired number of pre-allocated records for this variable in a SINGLE_FILE CDF file. Pre-allocating records ensures that variable data is stored contiguously in the CDF file. For discussion about allocating records, see “Records” in the CDF User’s Guide.

### DIMENSIONS

Set this keyword to create a new zVariable with the specified dimensions. If this keyword is not set, the variable is assumed to be a scalar. For example:

`id = CDF_CREATE("cdffile.cdf")`
`zid = CDF_VARCREATE(id, "Zvar", [1,1,1], \$`
`   DIM=[10,20,30], /CDF_INT4)`

Note: Variables created with the DIMENSIONS keyword set are always zVariables.

### NUMELEM

The number of elements of the data type at each variable value. This keyword only has meaning for string data types (CDF_CHAR, CDF_UCHAR). This is the number of characters in the string. The default is 1.

### REC_NOVARY

If this keyword is set, all records will contain the same information.

### REC_VARY

If this keyword is set, all records will contain unique data. This is the default.

### ZVARIABLE

Set this keyword to create a zVariable. For example:

`id = CDF_CREATE("cdffile.cdf")`
`zid = CDF_VARCREATE(id, "Zvar", /CDF_DOUBLE, /ZVARIABLE)`

Note: zVariables are much more efficient than rVariables in their use of disk space. Unless the recipient of your data set is using a very early version of CDF, you should always create zVariables.

Note: Variables created with the DIMENSIONS keyword set are always zVariables.

## Version History

 Pre 4.0 Introduced 6.3 Add support for the CDF_EPOCH16 variable type 6.4 Rename CDF_EPOCH16 keyword as CDF_LONG_EPOCH to avoid name conflict with CDF_EPOCH keyword.

© 2020 Harris Geospatial Solutions, Inc. |  Legal
{"ft_lang_label":"__label__en","ft_lang_prob":0.73479867,"math_prob":0.88023865,"size":4981,"snap":"2020-24-2020-29","text_gpt3_token_len":1283,"char_repetition_ratio":0.1599357,"word_repetition_ratio":0.06324111,"special_character_ratio":0.23368801,"punctuation_ratio":0.13716814,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9536775,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-14T13:18:00Z\",\"WARC-Record-ID\":\"<urn:uuid:3a7ff5d7-949a-4f21-bece-616b3e285928>\",\"Content-Length\":\"76480\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c69714b7-1e3b-49be-8296-c83e56c59388>\",\"WARC-Concurrent-To\":\"<urn:uuid:e7761a5a-0a6d-4213-b292-dabccddba282>\",\"WARC-IP-Address\":\"192.5.156.19\",\"WARC-Target-URI\":\"https://www.harrisgeospatial.com/docs/cdf_varcreate.html\",\"WARC-Payload-Digest\":\"sha1:QMKKWGWH6C744R7GUQ4Q4ANCJBBKQERK\",\"WARC-Block-Digest\":\"sha1:MIFYWNQKEBNGWXRBQYE6EFXZCSEHMQPQ\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655880665.3_warc_CC-MAIN-20200714114524-20200714144524-00413.warc.gz\"}"}