In [1]:
import iris

In [2]:
# calculate the current speed using a EPIC NetCDF file
url = 'http://geoport.whoi.edu/thredds/dodsC/usgs/data2/emontgomery/stellwagen/CF-1.6/RCNWR/9541aqd-cal.nc'

In [3]:
u = iris.load_cube(url,'eastward_sea_water_velocity')
v = iris.load_cube(url,'northward_sea_water_velocity')

In [4]:
print u


eastward_sea_water_velocity / (m/s) (time: 17425; height: 8)
     Dimension coordinates:
          time                           x              -
          height                         -              x
     Scalar coordinates:
          latitude: 43.2737388611 degrees
          longitude: -70.5867462158 degrees
     Attributes:
          AQDAnalogInput1: NONE
          AQDAnalogInput2: NONE
          AQDAnalogInputCal1: [-1471.  8826.]
          AQDAnalogInputCal2: [-1471.  8826.]
          AQDAnalogPowerLevel: LOW
          AQDAnalogPowerOutput: BATTERY
          AQDAverageInterval: 120.0
          AQDBeamAngle: 25.0
          AQDBeamPattern: convex
          AQDBeamWidth: 3.4
          AQDBlankingDistance: 0.4
          AQDCellSize: 50.0
          AQDCompassUpdateRate: 600.0
          AQDCoordinateSystem: BEAM
          AQDDeploymentName: 954aqd
          AQDDeploymentTime: 3/27/2013
          AQDFirmwareVersion: 3.38
          AQDFrequency: 1000.0
          AQDHeadRotation: horizontal
          AQDHeadSerialNumber: ASP 3795
          AQDMeasurementLoad: 75.0
          AQDNumberOfBeams: 3.0
          AQDNumberOfCells: 8.0
          AQDNumberOfPingsPerBurst: 6.0
          AQDPressRange: [   0.  100.]
          AQDPressureCal: [     0.      0.   3753.  12332.]
          AQDProfileInterval: 600.0
          AQDRecorderSize: 361 MByte
          AQDSalinity: 30.0 ppt
          AQDSerial_Number: AQD 5379
          AQDSoftwareVersion: 1.35
          AQDSoundSpeed: MEASURED
          AQDSyncOutDelay: 0 sec
          AQDSyncPowerDelay: 0 sec
          AQDTempRange: [ -4.  40.]
          AQDTransMatrix: [ 1.5774  0.      0.3677 -0.7891 -1.3662  0.3677 -0.7891  1.3662  0.36...
          AQDTransmitPulseLength: 0.50 m
          AQDVelRange: 1000.0
          COMPOSITE: 0.0
          COORD_SYSTEM: GEOGRAPHIC
          ClockError: 0.0
          Conventions: CF-1.6
          DATA_CMNT: early termination on 7/26 due to instrument failure
          DATA_ORIGIN: USGS WHSC Sed Trans Group
          DATA_SUBTYPE: MOORED
          DELTA_T: 600
          DEPTH_CONST: 0.0
          DESCRIPTION: Under Bourne Ave. Bridge
          DODS.dimName: feature_type_instance
          DODS.strlen: 11
          DODS_EXTRA.Unlimited_Dimension: time
          DRIFTER: 0.0
          Deployment_date: 27-Mar-2013
          EXPERIMENT: Rachel Carson National Wildlife Refuge 2013
          FORTRAN_format:  
          INST_TYPE: Nortek Aquadopp Profiler
          LatLonDatum: NAD83
          MOORING: 954
          POS_CONST: 0.0
          PROJECT: USGS Coastal Marine Geology Program
          Recovery_date: 9-Dec-2013
          SciPi: N. Ganju
          WATER_DEPTH: 2.82962687162
          WATER_DEPTH_NOTE: (meters), nominal depth
          WATER_DEPTH_datum: MSL
          WATER_DEPTH_source: Water depth determined by mean pressure value
          WATER_MASS: ?
          WaveMeasurements: DISABLED
          _ChunkSize: [1000    8]
          actual_max: 168.253
          actual_min: -63.2215
          beam_angle: 25.0
          beam_pattern: convex
          beam_width: 3.4
          bin_count: 8.0
          bin_size: 0.5
          blanking_distance: 0.4
          center_first_bin: 0.9
          contributor_name: N. Ganju
          contributor_role: principalInvestigator
          creator_email: rsignell@usgs.gov
          creator_name: Rich Signell
          creator_phone: +1 (508) 548-8700
          creator_url: http://www.usgs.gov
          date_created: 2015-08-12T20:39:00Z
          epic_code: 1205
          featureType: timeSeriesProfile
          feneric_name: u
          fileRoot: 9541aqdoldnc
          fixgaps: 1.0
          frequency: 1000.0
          geospatial_lat_max: 43.2737
          geospatial_lat_min: 43.2737
          geospatial_lon_max: -70.5867
          geospatial_lon_min: -70.5867
          geospatial_vertical_max: 1.34037312838
          geospatial_vertical_min: -2.15962687162
          geospatial_vertical_positive: up
          geospatial_vertical_resolution: 0.5 0.5 0.5 0.5 0.5 0.5 0.5
          height_depth_units: m
          history: Data cropped by user defined ensemble numbers;Data rotated into Earth Coordinates...
          id: 9541aqd-cal
          initial_instrument_height: 0.25
          initial_instrument_height_note: from mooring log
          initial_sensor_height: 0.25
          inst_height: 0.25
          institution: USGS Woods Hole Coastal and Marine Science Center
          institution_url: http://woodshole.er.usgs.gov
          instrument_type: Nortek Aquadopp Profiler
          keywords: Oceans > Ocean Pressure > Water Pressure, Oceans > Ocean Temperature >...
          keywords_vocabulary: GCMD Science Keywords
          latitude: 43.27374
          longitude: -70.58675
          magnetic_variation: 99.0
          magnetic_variation_applied: 99.0
          metadatafile_author: Ellyn Montgomery, USGS CMGP
          metadatafile_name: emrun954AQDprfoldnc
          metadatafile_version: 0.0
          name: u_1205
          naming_authority: gov.usgs.cmgp
          nominal_sensor_depth: 2.57962687162
          nominal_sensor_depth_note: WATER_DEPTH-initial_instrument_height
          orientation: UP
          original_filename: 9541aqd-cal.nc
          original_folder: RCNWR
          platform: I-mount 
          platform_type: I frame bottom mount
          pred_accuracy: 4.8
          project: Coastal and Marine Geology Program
          project_summary: Oceanographic and water-quality observations made at 3 sites in the wetlands...
          project_title: Rachel Carson NWR 2013
          publisher_email: emontgomery@usgs.gov
          publisher_name: Ellyn Montgomery
          publisher_phone: +1 (508) 548-8700
          publisher_url: http://www.usgs.gov
          salinity_set_by_user: 30.0 ppt
          salinity_set_by_user_units: ppt
          sensor_depth: -2.57962687162
          sensor_type: Nortek Aquadopp Profiler
          serial_number: AQD 5379
          source: USGS
          standard_name_vocabulary: CF-1.6
          start_time: 03-Mar-2013 13:31:00
          stop_time: 26-July-2013 01:30:59
          time_coverage_duration: P10454399S
          time_coverage_end: 2013-07-26T01:30:59
          time_coverage_resolution: P600S
          time_coverage_start: 2013-03-27T01:31:00
          title: RCNWR - 9541aqd-cal.nc
          transducer_offset_from_bottom: 0.25
          zeroed_pressure: Yes

In [5]:
u.name()


Out[5]:
u'eastward_sea_water_velocity'

In [6]:
def calc_speed(u, v):
    """Calculate the speed"""

    speed = (u**2 + v**2)**0.5

    return speed

In [9]:
spData = calc_speed(u,v)

In [10]:
print spData


unknown / (meter-second^-1)         (time: 17425; height: 8)
     Dimension coordinates:
          time                           x              -
          height                         -              x
     Scalar coordinates:
          latitude: 43.2737388611 degrees
          longitude: -70.5867462158 degrees

In [8]: