Difference between revisions of "Seedme"

(SeedMe Python Module Example)
(VisIt [https://www.seedme.org/ SeedMe.org] Integration)
Line 6: Line 6:
 
* SeedMe Python module (version 2.9.0+): Useful for scripting/automation purposes
 
* SeedMe Python module (version 2.9.0+): Useful for scripting/automation purposes
  
Below are simple examples for using SeedMe.org from visit.  
+
[['''Use case for VisIt users''']]
 +
Video generation such that it will playback on different devices is very cumbersome, as they require different bitrates and codec profiles. SeedMe.org provides this video capability along with sharing for easy collaboration. Furthermore, users are not limited to creating and sharing videos, you may describe each video, and share other relevant data. Below are simple examples for using SeedMe.org from visit.  
  
  

Revision as of 20:48, 14 November 2016

VisIt SeedMe.org Integration

SeedMe.org provides video encoding (from images), data sharing, description and discussion capabilities that may be convenient for collaboration. VisIt provides two methods to upload content to SeedMe.org

  • SeedMe Graphical Widget: Available under File > SeedMe menu (version 2.12.x+)
  • SeedMe Python module (version 2.9.0+): Useful for scripting/automation purposes

'''Use case for VisIt users''' Video generation such that it will playback on different devices is very cumbersome, as they require different bitrates and codec profiles. SeedMe.org provides this video capability along with sharing for easy collaboration. Furthermore, users are not limited to creating and sharing videos, you may describe each video, and share other relevant data. Below are simple examples for using SeedMe.org from visit.


Setup your SeedMe Account

  • Sign-up at SeedMe.org. We recommend using CILogon option which enables you to use your institution credentials.


TASK: Create and Share Video from an Image Sequence

In this example we create a simple animation using VisIt, then upload 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.


SeedMe Graphical Widget Example

Create an animation image sequence

  • Download tutorial_data and unzip it
  • Start VisIt,
  • Under wave_data directory open file wave*.silo database
  • Add > Psuedocolor > Pressure
  • File > Save Movie > New simple movie > Under Choose format | PNG images > Choose filename | set Output directory as desired > Keep all other settings as is

Encode video from this image sequence and share it with others

  • Peform SeedMe account setup as described above. Your SeedMe APIKey must be in your home folder
  • File > SeedMe
  • Sharing > Group
  • Collection title > Test movie
  • Share emails > one@example.com (use space separated emails)
  • Browse > Select all png images that were rendered above
  • Submit | This will upload the images and create a video at 10 frames per second and also share it with one@example.com
  • Click on the link to open the video in a web browser

OR

  • Download video | Available after uploading images. Choose Quality of videos for download. Note: It may take several minutes for videos to be generated and available


SeedMe Python Module Example

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

To run this example, you may use one of the following paths:

  • 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
#############################################################################
# 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
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
    satts.displayEndFlag = 1
    swatts.fileName = "seedme_streamline_crop_example_%04d.png" % ts
    SetPlotOptions(satts)
    DrawPlots()
    SetSaveWindowAttributes(swatts)
    SaveWindow()
    

#############################################################################
# Now publish this sequence to SeedMe
#############################################################################
# Silence InsecurePlatformWarning for some Python versions prior to 2.7.9
# Reference https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning
#import logging
#logging.captureWarnings(True)

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 other add_* methods
#   Query and list content using query() method
#   Download content using download() method
#   See all methods available at https://www.seedme.org/help/programmatic/python/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 using web browser at
####
print ('View your collection using web browser at: https://www.seedme.org/node/' + my_cid)


####
# Download the video for the above sequence using download() method
####
# Notes: 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.
#            Programmatic download is only supported for Public collections for all files except (sequences)
#            These limitations will be fixed in future. 
#            All collections can be viewed and download via web browser

# 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)


####
# Clean up by deleting the seedme object
####
del obj

For more detailed example, see demo.py and the Seedme command line guide.