#NEWLINE# @ classmethod #NEWLINE# def from_gridspec( cls , gridspec_file , lenuni = 0 ) : #NEWLINE# #INDENT# f = open ( gridspec_file , 'r' ) #NEWLINE# lines = f . readlines ( ) #NEWLINE# raw = f . readline ( ) . strip ( ) . split ( ) #NEWLINE# nrow = int ( raw [ 0 ] ) #NEWLINE# ncol = int ( raw [ 1 ] ) #NEWLINE# raw = f . readline ( ) . strip ( ) . split ( ) #NEWLINE# ( xul , yul , rot ) = ( float ( raw [ 0 ] ) , float ( raw [ 1 ] ) , float ( raw [ 2 ] ) ) #NEWLINE# delr = [ ] #NEWLINE# j = 0 #NEWLINE# while ( j < ncol ) : #NEWLINE# #INDENT# raw = f . readline ( ) . strip ( ) . split ( ) #NEWLINE# for r in raw : #NEWLINE# #INDENT# if ( '*' in r ) : #NEWLINE# #INDENT# rraw = r . split ( '*' ) #NEWLINE# for n in range ( int ( rraw [ 0 ] ) ) : #NEWLINE# #INDENT# delr . append ( int ( rraw [ 1 ] ) ) #NEWLINE# j += 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# delr . append ( int ( r ) ) #NEWLINE# j += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# delc = [ ] #NEWLINE# i = 0 #NEWLINE# while ( i < nrow ) : #NEWLINE# #INDENT# raw = f . readline ( ) . strip ( ) . split ( ) #NEWLINE# for r in raw : #NEWLINE# #INDENT# if ( '*' in r ) : #NEWLINE# #INDENT# rraw = r . split ( '*' ) #NEWLINE# for n in range ( int ( rraw [ 0 ] ) ) : #NEWLINE# #INDENT# delc . append ( int ( rraw [ 1 ] ) ) #NEWLINE# i += 1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# delc . append ( int ( r ) ) #NEWLINE# i += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# f . close ( ) #NEWLINE# return cls ( np . array ( delr ) , np . array ( delc ) , lenuni , xul = xul , yul = yul , rotation = rot )