Difference between revisions of "Seedme"

(Example Script)
(Example Script)
Line 174: Line 174:
 
                               sequences=my_sequence)
 
                               sequences=my_sequence)
  
# Extract collection id from result which may be used to
+
# Extract collection id from result
#  Update/append content
 
#  Query and list content
 
 
my_cid = obj.get_id(result)
 
my_cid = obj.get_id(result)
 +
 +
# Once we have the collection ID, we may
 +
#  Update/append content using update_collection() method or any methods available
 +
#  Query and list content using query() method
 +
#  Download content using download() method
 +
#  See all methods available at https://www.seedme.org/documentation/python-client-methods
  
 
# For example  
 
# For example  

Revision as of 17:57, 19 February 2015

VisIt SeedMe.org Integration

Share your visualizations results easily via the SeedMe python module which is now included in VisIt, starting with version 2.9.0. This page provides a short example of how you can use VisIt and the SeedMe python module.

For more examples of how to use Seedme, see the the Seedme Python programatic guide, the examples in demo.py and the Seedme command line guide.


Setup your SeedMe Account

Create and Share Video from an Image Sequence

This example creates a simple visualization using VisIt and uploads rendered images from this visualization to SeedMe.org to create video from it at desired frame rate. Videos are created at several different resolutions automatically. These may be downloaded, played back on many devices or shared with others easily.

This script uses 'example.silo' data, which can be obtained here.

To run this example, here are two paths you can take:

  • Open VisIt and make sure 'example.silo' is open and the selected active database.
  • Copy and paste this script into an empty tab in VisIt's `Commands` window and click execute.

Or

  • Save this script as "visit_seedme_post_example.py" and run using:
  visit -o example.silo -nowin -cli -s visit_seedme_post_example.py

Example Script

#############################################################################
# file: visit_seedme_post_example.py
#
# note: This script uses 'example.silo' data,  which can be obtained from:
# http://portal.nersc.gov/project/visit/cyrush/sc13/visit_tutorial_data.tar.gz
#
# usage:
# 
#  Make sure 'example.silo' is open and the selected active database.
#  Copy and paste this script into an empty tab in VisIt's `Commands` 
#  window and click execute.
#
# or download as "visit_seedme_post_example.py" and run using:
#  >visit -o example.silo -nowin -cli -s visit_seedme_post_example.py
#
#############################################################################

#############################################################################
# We create an image sequence of cropped streamlines starting with one of 
# the VisIt scripting  tutorials.
# http://visitusers.org/index.php?title=VisIt-tutorial-Python-scripting#Using_all_of_VisIt.27s_Building_Blocks
#############################################################################

# clear any previous plots
DeleteAllPlots()
# Create a plot of the scalar field 'temp'
AddPlot("Pseudocolor","temp")
# Slice the volume to show only three
# external faces.
AddOperator("ThreeSlice")
tatts = ThreeSliceAttributes()
tatts.x = -10
tatts.y = -10
tatts.z = -10
SetOperatorOptions(tatts)
DrawPlots()
# Find the maximum value of the field 'temp'
Query("Max")
val = GetQueryOutputValue()
print "Max value of 'temp' = ", val
# Create a streamline plot that follows
# the gradient of 'temp'
DefineVectorExpression("g","gradient(temp)")
AddPlot("Streamline","g")
satts = StreamlineAttributes()
satts.sourceType = satts.SpecifiedBox
satts.sampleDensity0 = 7
satts.sampleDensity1 = 7
satts.sampleDensity2 = 7
satts.displayMethod = satts.Tubes
satts.coloringMethod = satts.ColorBySeedPointID
satts.referenceTypeForDisplay = satts.Time
SetPlotOptions(satts)
DrawPlots()

#
# To extend this example to create an image sequence,  
# we animate the path of these streamlines.
#

# Setup a better view
ResetView()
v = GetView3D()
v.RotateAxis(0,44)
v.RotateAxis(1,-23)
SetView3D(v)

# Disable annotations
aatts = AnnotationAttributes()
aatts.axes3D.visible = 0
aatts.axes3D.triadFlag = 0
aatts.axes3D.bboxFlag = 0
aatts.userInfoFlag = 0
aatts.databaseInfoFlag = 0
aatts.legendInfoFlag = 0
satts.displayEndFlag = 1
satts.displayEnd = 0
SetAnnotationAttributes(aatts)

# Setup basic save options
swatts = SaveWindowAttributes()
swatts.family = 0
swatts.format = swatts.PNG 
swatts.width = 1024
swatts.height = 1024


####
# Render cropped streamlines at increasing time values
####
for ts in range(0,50):
    satts.displayEnd = ts * .5
    swatts.fileName = "seedme_streamline_crop_example_%04d.png" % ts
    SetPlotOptions(satts)
    DrawPlots()
    SetSaveWindowAttributes(swatts)
    SaveWindow()
    

#############################################################################
# Now publish this sequence to SeedMe
#############################################################################

import seedme
# Create an object from SeedMe class
obj = seedme.SeedMe()

# Set path for authorization file if not stored in your home folder or renamed. 
# obj.set_auth_via_file('/path/seedme.txt') 

# Now post/upload this image sequence to SeedMe

# Create a dictionary about image sequence as follows
my_sequence = {'filepath': 'seedme_streamline_crop_example_*png', 
# Required, this may be a directory (not read recursively) or wildcard path 
               'title': 'Example Cropped Streamline Paths',  # Recommended
               'fps': '24', # Frame rate for video (default:30) #optional
               'encode': True, # Create video from this sequence (default:False) #optional
              }

# Set privacy of collection as one of private(default), group or public
my_privacy = 'public'


# Emails (comma separated) with whom you wish to share this collection
my_list = 'test1@seedme.org, test2@seedme.org'


# Notify the above people once uploaded (Default: False)
my_notify = True


# Create a new collection using create_collection() method that
#   Uploads all specified contents
#   Returns a JSON string response with status and collection_id 

result = obj.create_collection(privacy=my_privacy,
                               sharing=my_list,
                               notify=my_notify,
                               title='VisIt Seedme Example Collection',
                               tags='VisIt',
                               sequences=my_sequence)

# Extract collection id from result
my_cid = obj.get_id(result)

# Once we have the collection ID, we may 
#   Update/append content using update_collection() method or any methods available
#   Query and list content using query() method
#   Download content using download() method
#   See all methods available at https://www.seedme.org/documentation/python-client-methods

# For example 
# Upload another sequence to this collection
# obj.add_sequence(my_cid, filepath='/path/to/*png', title='Another sequence', description=None, fps=30, encode=True)
# 
# Upload a single file to this collection
# obj.add_file(my_cid, filepath='/path/to/file', title='A simple file', description=None)

# View your collection at 
print ('View your collection at: https://www.seedme.org/node/' + my_cid)

# Download the video for the above sequence using download() method
# Note: Video encoding may take few seconds to several minutes, 
# so we must wait before trying/retrying to download the videos.
# You may add a sleep/pause here for some duration


# download() method parameters
# cid = Collection ID
# content = one of 'all' or 'video' or wildcard for example *png
# path = path to save the downloaded files
# retry = number of time to retry download. Default: 3
# interval = number of seconds to wait before retry. Default: 60

obj.download(cid=my_cid, content='video', path='~/Desktop', retry=3, interval=120)


# Note: Download is currently only supported for Public Collections, also
# downloading of sequence files is not supported presently, but will be soon.
# Private and Group Collections currently require web browser login for viewing/download

# Clean up by deleting the seedme object
del obj